Jayce
Another simple template engine. Just a little different.
Usage
npm install jayce
var jayce = var render = jaycevar data = ... var html =
Or render directly (recommend)
var jayce = var data = ... var html = jayce
In browser, you can use jayce.min.js
, support AMD, CMD, or global mode.
Syntax
Variable
Wrap with {}
, and end with $
.
{content$}
Filters
Make up your filter for variables like this:
jayce
{content | format $}
Condition
Wrap with {}
too. And more like this:
{user < 0?} negative {user == 0:?} zero {:?} positive {/?}
Traverse
Really simple: (Also support object)
{list, item, key@} {key$}:{item$} {/@}
Html Entities encode
Default, all html entities in variables will be encoded. You can cancel by #
:
{#content$}
Incorrect type
{:?}
Will not throw error, it will output:
{:?}
Develop
Now there are some simple test cases in ./test
. Run:
npm test
TODO
- Easier to debug.
- Functional features.
- More test.
- More Benchmarks.
- High preformance.