1.0.10 • Published 1 year ago

sgt v1.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

{Seagull Templates}

An easy-to-use template engine

Features

  • Loop, if and else logic
  • Manipulate string outputs with output tags
  • Includes (relative and absolute path)
  • Compatible with MuxJS

Output tags

  • Escape with &=
  • Unescape with &-
  • Trim whitespace with %-
  • Upper case with @=
  • Lower case with @-
  • Capitalize output with @
  • Capitalize every word with @~

Code example

const sgt = require("sgt")

//Compile a string
sgt.Compile("<h1>{{ name }}</h1>", { name: "Seagull" })
// => "<h1>Seagull</h1>"

//Output tag "&=" like mentioned above escapes the output
sgt.Compile("{{&= tag }}", { tag: "<script>alert('Seagull!')</script>" })
// => "&lt;script&gt;alert(&#39;Seagull!&#39;)&lt;/script&gt;"

//Compile a file
sgt.CompileFile("path/to/file/file.html", { name: "Seagull" })

Installation

$ npm install sgt

Example

Confused? Test and view the example, clone the sgt repo and install the dependencies:

 $ git clone https://github.com/robin-andreasson/sgt
 $ cd sgt
 $ git sparse-checkout set example
 $ cd example
 $ npm install
 $ node index
1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.0

1 year ago