saxt
SAX T(emplate)
A server-side template engine based on sax-js
Install
npm i saxt
Usage
saxt has a very simple syntax.
All tagName
is html tag. The attr
can be static value or wrapped with {}
, then it will bind view props, and one special attr is children
. If attr is children
, the attrValue will be passed to the children element.
Important: If the bind value is not a string type, it will be stringify by JSON.stringify
and encoded by encodeURIComponent
The saxt()
will return a readable stream, like:
const saxt = const view = foo: "bar" const stream = let result = ''stream stream
Example
const saxt = const view = post: `<div> <p>hello world</p> </div>` charset: 'utf8' // 1. children example // result >>><div ="post"><div> <p>hello world</p></div></div> // 2. attr example // result >>>><meta ="utf8"></meta>
License
MIT License