Input values other than string will be rendered in specific way.
Used option: FLAG_JSTRUE
array(
"foo" => true
)
true
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{{foo}}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSTRUE
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => true
);
echo $render($data);
{
"foo": true
}
true
var Handlebars = require('handlebars');
var template = '{{{foo}}}';
var render = Handlebars.compile(template);
var data = {
"foo": true
};
console.log(render(data));
{
"foo": true
}
true
var Mustache = require('mustache');
var template = '{{{foo}}}';
var data = {
"foo": true
};
console.log(Mustache.render(template, data));
Used option: FLAG_JSTRUE
array(
"foo" => false
)
false
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{{foo}}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSTRUE
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => false
);
echo $render($data);
{
"foo": false
}
false
var Handlebars = require('handlebars');
var template = '{{{foo}}}';
var render = Handlebars.compile(template);
var data = {
"foo": false
};
console.log(render(data));
{
"foo": false
}
false
var Mustache = require('mustache');
var template = '{{{foo}}}';
var data = {
"foo": false
};
console.log(Mustache.render(template, data));
Used option: FLAG_JSOBJECT
array(
"foo" => array(
"bar" => "foo is object"
)
)
[object Object]
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{{foo}}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSOBJECT
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"bar" => "foo is object"
)
);
echo $render($data);
{
"foo": {
"bar": "foo is object"
}
}
[object Object]
var Handlebars = require('handlebars');
var template = '{{{foo}}}';
var render = Handlebars.compile(template);
var data = {
"foo": {
"bar": "foo is object"
}
};
console.log(render(data));
{
"foo": {
"bar": "foo is object"
}
}
[object Object]
var Mustache = require('mustache');
var template = '{{{foo}}}';
var data = {
"foo": {
"bar": "foo is object"
}
};
console.log(Mustache.render(template, data));
Used option: FLAG_JSOBJECT
array(
"foo" => array(
"is",
"an",
"array"
)
)
is,an,array
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{{foo}}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSOBJECT
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"is",
"an",
"array"
)
);
echo $render($data);
{
"foo": [
"is",
"an",
"array"
]
}
is,an,array
var Handlebars = require('handlebars');
var template = '{{{foo}}}';
var render = Handlebars.compile(template);
var data = {
"foo": [
"is",
"an",
"array"
]
};
console.log(render(data));
{
"foo": [
"is",
"an",
"array"
]
}
is,an,array
var Mustache = require('mustache');
var template = '{{{foo}}}';
var data = {
"foo": [
"is",
"an",
"array"
]
};
console.log(Mustache.render(template, data));
Used option: FLAG_JSOBJECT
NULL
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{{foo}}}";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSOBJECT
));
$render = LightnCandy::prepare($php);
$data = NULL;
echo $render($data);
null
var Handlebars = require('handlebars');
var template = '{{{foo}}}';
var render = Handlebars.compile(template);
var data = null;
console.log(render(data));
null
Cannot read property 'foo' of null
var Mustache = require('mustache');
var template = '{{{foo}}}';
var data = null;
console.log(Mustache.render(template, data));