
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
var jeyson = require('jeyson').create(),
scope = {message: 'Hello!'},
templateJson = {"message": "{{message}}"},
compiled = jeyson.compile(scope, templateJson);
An expression is defined as '{{expr}}'
Following template.json :
{
"age": "{{21 + 33}}"
}
is compiled to
{
"age": 54
}
Any valid javascript snippet is a valid expression, e.g following template.json :
{
"list" : "{{'one,two,three,four,five'.split(',')}}",
}
is compiled to
{
"list" : ["one", "two", "three", "four", "five"],
}
Any field on scope object, is available as local variable in expressions.
e.g. Given scope defined as :
var scope = {message: "Hello !"},
then following template.json :
{
"message": "{{message}}"
}
is compiled to
{
"message": "Hello !"
}
e.g. Given scope defined as :
var scope = {
message: function(){
return "Hello !";
}
};
then following template.json :
{
"message": "{{message()}}"
}
is compiled to
{
"message": "Hello !"
}
E.g.
{
"list" : {
"@repeat" : "name in ['one','two','three','four','five']",
"id" : "{{$index + 1}}",
"name" : "{{name}}",
}
}
It will compile to following json :
{
"list": [ {"id": "1","name" : "one"},
{"id": "2","name" : "two"},
{"id": "3","name" : "three"},
{"id": "4","name" : "four"},
{"id": "5","name" : "five"}];
}
Following are the conditional directives
scope = {role : {name: "admin"}}
template = {
"user" : {
"role" : {
"@switch" : "role.name",
"@admin" : {"name" : "admin"},
"@visitor" : {"name" : "visitor"},
"@default" : {"name" : "guest"}
}
}
Will compile to
template = {
"user" : {
"role" : {"name" : "admin"}
}
{
"author" : "ABC",
"book" : {
"@if" : "1 == 2",
"@then" : {"title" : "Harry Potter"}
"@else" : "unknown",
}
}
will result in
{
"author" : "ABC",
"book" : "unknown"
}
{
"author" : "ABC",
"book" : {
"@if" : "1 == 1",
"@then" : {"title" : "Harry Potter"}
}
will result in
{
"author" : "ABC",
"book" : {"title" : "Harry Potter"}
}
{
"author" : "ABC",
"book" : {
"@if" : "1 == 2",
"@then" : {"title" : "Harry Potter"}
}
will result in
{
"author" : "ABC",
"book" : null
}
e.g
{
"author" : "ABC",
"book" : {
"@ignore-if": "1 == 1",
"title" : "Harry Potter"
}
}
will result in
{
"author" : "ABC"
}
Inbuilt directives for repeating, including other json etc.
FAQs
Json template engine
The npm package jeyson receives a total of 3 weekly downloads. As such, jeyson popularity was classified as not popular.
We found that jeyson demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.