Jexpr is designed for libraries that evaluate user-written expressions, such as HTML templating engines. Jexpr has a relatively rich syntax, supportin

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-11-18 18:00:04

Jexpr is designed for libraries that evaluate user-written expressions, such as HTML templating engines. Jexpr has a relatively rich syntax, supporting identifiers, operators, property access, method and function calls, and literals (including arrays and objects), function literals, assignments, and pipes.

parse() takes an AST factory so that different strategies can be used to produce ASTs. The default factory creates an AST as defined in lib/ast.js. lib/eval.js exports an EvalAstFactory that produces evaluatable ASTs.

Expressions are generally null-safe. If a subexpression yields null or undefined, subsequent property access will return null, rather than throwing an exception. Property access, method invocation and operators are null-safe. Passing null to a function that doesn't handle null will not be null safe.

Properties on the model and in the scope are looked up via simple property names, like foo. Property names are looked up first in the top-level variables, next in the model, then recursively in parent scopes. Properties on objects can be access with dot notation like foo.bar.

Leave a Comment