lightncandy
Partials:Data:array("foo"=>"World")
Template:Hello,{{>world}}
Source Code
require('./vendor/autoload.php');useLightnCandy\LightnCandy;$template="Hello, {{> world}}";$php=LightnCandy::compile($template,array("partials"=>array("world"=>"{{foo}}!")));$render=LightnCandy::prepare($php);$data=array("foo"=>"World");echo$render($data);
handlebars.js
Partials:Template:Hello,{{>world}}
Source Code
var Handlebars=require('handlebars');var template='Hello, {{> world}}';var render= Handlebars.compile(template);var data={"foo":"World"};console.log(render(data,{partials:{"world":"{{foo}}!"}}));
mustache
Partials:Template:Hello,{{>world}}
Source Code
var Mustache=require('mustache');var template='Hello, {{> world}}';var data={"foo":"World"};console.log(Mustache.render(template, data,{"world":"{{foo}}!"}));
lightncandy
Used option: FLAG_JSOBJECT
Partials:world | {{foo}}! |
---|
hello | {{bar}}! |
---|
Data:array("foo"=>"World","bar"=>array("foo"=>"YA!"))
Template:{{>hello}},{{>world}}Foo:{{#bar}}{{>world}}{{/bar}}
Result:[object Object]!, World!Foo: YA!!
Source Code
require('./vendor/autoload.php');useLightnCandy\LightnCandy;$template="{{>hello}}, {{> world}}\nFoo: {{#bar}}{{> world}}{{/bar}}";$php=LightnCandy::compile($template,array("flags"=>LightnCandy::FLAG_JSOBJECT,"partials"=>array("world"=>"{{foo}}!","hello"=>"{{bar}}!")));$render=LightnCandy::prepare($php);$data=array("foo"=>"World","bar"=>array("foo"=>"YA!"));echo$render($data);
handlebars.js
Partials:world | {{foo}}! |
---|
hello | {{bar}}! |
---|
Data:{"foo":"World","bar":{"foo":"YA!"}}
Template:{{>hello}},{{>world}}Foo:{{#bar}}{{>world}}{{/bar}}
Result:[object Object]!, World!Foo: YA!!
Source Code
var Handlebars=require('handlebars');var template='{{>hello}}, {{> world}}\nFoo: {{#bar}}{{> world}}{{/bar}}';var render= Handlebars.compile(template);var data={"foo":"World","bar":{"foo":"YA!"}};console.log(render(data,{partials:{"world":"{{foo}}!","hello":"{{bar}}!"}}));
mustache
Partials:world | {{foo}}! |
---|
hello | {{bar}}! |
---|
Data:{"foo":"World","bar":{"foo":"YA!"}}
Template:{{>hello}},{{>world}}Foo:{{#bar}}{{>world}}{{/bar}}
Result:[object Object]!, World!Foo: YA!!
Source Code
var Mustache=require('mustache');var template='{{>hello}}, {{> world}}\nFoo: {{#bar}}{{> world}}{{/bar}}';var data={"foo":"World","bar":{"foo":"YA!"}};console.log(Mustache.render(template, data,{"world":"{{foo}}!","hello":"{{bar}}!"}));