Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "jeyson", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Json template engine", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -1,15 +0,15 @@ | ||
## JSO-NG | ||
- JSO-NG is a templating language for serving json content. | ||
- It extends the notion of compiling html templates to json. | ||
## Jeyson Templates | ||
- Every json is a valid template in itself. | ||
- The templates can have expressions, which can execute javascript. | ||
- These templates are compiled in context of a scope. | ||
- The templates can have expressions, which can manipulate scope and execute javascript. | ||
- Directives can pass instructions to compiler. | ||
- Inbuilt directives for repeating, including other json etc. | ||
- Custom directives can replace/modify template body, execute expressions, read other templates. | ||
### Compiling Templates | ||
```javascript | ||
var jsong = require('jso-ng').create(), | ||
var jeyson = require('jeyson').create(), | ||
scope = {message: 'Hello!'}, | ||
templateJson = '{"message": "{{message}}"}', | ||
compiled = compiler.compile(scope , templateJson); | ||
compiled = jeyson.parse(scope, templateJson); | ||
``` | ||
@@ -33,3 +33,3 @@ | ||
### Javascript as expression. | ||
### Javascript in Expressions. | ||
Any valid javascript snippet is a valid expression, e.g following __template.json__ : | ||
@@ -91,4 +91,5 @@ ```javascript | ||
### Directives | ||
- Directive as a name starting with __"@"__ | ||
- Directive body is any field in json with child field's name starting with __"@"__' | ||
- Directive is a field with name starting with __"@"__ | ||
- Directive __body__ is the parent subtree of directive field | ||
- Directive argument is the value of directive field. | ||
@@ -100,3 +101,3 @@ E.g. | ||
"@repeat" : "name in ['one','two','three','four','five']", | ||
"id" : "{{$index}}", | ||
"id" : "{{$index + 1}}", | ||
"name" : "{{name}}", | ||
@@ -124,8 +125,17 @@ } | ||
### Inbuilt Directives | ||
Inbuilt directives for repeating, including other json etc. | ||
### @repeat | ||
- $index | ||
- array | ||
- result | ||
### Custom Directives | ||
- Modifying | ||
- Modifying | ||
- Replacing directive contents | ||
- Source code of inbuilt directives | ||
- Reading scope | ||
- Executing expressions | ||
- Modifying body | ||
- Replacing body | ||
- Reading other templates by relative path | ||
### Source code of inbuilt directives | ||
@@ -135,1 +145,2 @@ | ||
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25059
142
1