Expression Compiler
- write a custom grammar
- in your grammar, return one of the token types for javascript (i.e. define how the AST should look)
- the compiler will automatically convert that to a function for you, to call against a scope
Install
node:
$ npm install expressionjs-compiler
browser:
$ component install expressionjs/compiler
API
- hash-with-interpolation
- hash
- attribute
- filters
- filter
- interpolations
- interpolation
- call
- assignment
- ternary
- binary
- unary
- literal
Notes
iterator
hash-with-interpolation
hash
attribute
filters
filter
interpolations
interpolation
call
assignment
ternary
binary
unary
literal
filter-expression: exp1 | filter1:exp2 | filtern: expn
iterator-expression: exp1 for name in exp2
iterator-expression: exp1 group by exp2 for name in exp3
hash-expression: key1: exp1, key2: exp2, ..., key2: expn
hash-expression: key1: string + {{exp1}} + ... + {{expn}}
expression: string + {{exp1}} + ... + {{expn}}
Licence
MIT