Specific Values

Input values other than string will be rendered in specific way.

Samples


lightncandy

Used option: FLAG_JSTRUE

Data:
array(
  "foo" => true
)
Template:
{{{foo}}}
Result:
true
Source Code
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);
handlebars.js
Data:
{
  "foo": true
}
Template:
{{{foo}}}
Result:
true
Source Code
var Handlebars = require('handlebars');
var template = '{{{foo}}}';

var render = Handlebars.compile(template);
var data = {
  "foo": true
};
console.log(render(data));
mustache
Data:
{
  "foo": true
}
Template:
{{{foo}}}
Result:
true
Source Code
var Mustache = require('mustache');
var template = '{{{foo}}}';

var data = {
  "foo": true
};
console.log(Mustache.render(template, data));

lightncandy

Used option: FLAG_JSTRUE

Data:
array(
  "foo" => false
)
Template:
{{{foo}}}
Result:
false
Source Code
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);
handlebars.js
Data:
{
  "foo": false
}
Template:
{{{foo}}}
Result:
false
Source Code
var Handlebars = require('handlebars');
var template = '{{{foo}}}';

var render = Handlebars.compile(template);
var data = {
  "foo": false
};
console.log(render(data));
mustache
Data:
{
  "foo": false
}
Template:
{{{foo}}}
Result:
false
Source Code
var Mustache = require('mustache');
var template = '{{{foo}}}';

var data = {
  "foo": false
};
console.log(Mustache.render(template, data));

lightncandy

Used option: FLAG_JSOBJECT

Data:
array(
  "foo" => array(
    "bar" => "foo is object"
  )
)
Template:
{{{foo}}}
Result:
[object Object]
Source Code
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);
handlebars.js
Data:
{
  "foo": {
    "bar": "foo is object"
  }
}
Template:
{{{foo}}}
Result:
[object Object]
Source Code
var Handlebars = require('handlebars');
var template = '{{{foo}}}';

var render = Handlebars.compile(template);
var data = {
  "foo": {
    "bar": "foo is object"
  }
};
console.log(render(data));
mustache
Data:
{
  "foo": {
    "bar": "foo is object"
  }
}
Template:
{{{foo}}}
Result:
[object Object]
Source Code
var Mustache = require('mustache');
var template = '{{{foo}}}';

var data = {
  "foo": {
    "bar": "foo is object"
  }
};
console.log(Mustache.render(template, data));

lightncandy

Used option: FLAG_JSOBJECT

Data:
array(
  "foo" => array(
    "is",
    "an",
    "array"
  )
)
Template:
{{{foo}}}
Result:
is,an,array
Source Code
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);
handlebars.js
Data:
{
  "foo": [
    "is",
    "an",
    "array"
  ]
}
Template:
{{{foo}}}
Result:
is,an,array
Source Code
var Handlebars = require('handlebars');
var template = '{{{foo}}}';

var render = Handlebars.compile(template);
var data = {
  "foo": [
    "is",
    "an",
    "array"
  ]
};
console.log(render(data));
mustache
Data:
{
  "foo": [
    "is",
    "an",
    "array"
  ]
}
Template:
{{{foo}}}
Result:
is,an,array
Source Code
var Mustache = require('mustache');
var template = '{{{foo}}}';

var data = {
  "foo": [
    "is",
    "an",
    "array"
  ]
};
console.log(Mustache.render(template, data));

lightncandy

Used option: FLAG_JSOBJECT

Data:
NULL
Template:
{{{foo}}}
Result:
Source Code
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);
handlebars.js
Data:
null
Template:
{{{foo}}}
Result:
Source Code
var Handlebars = require('handlebars');
var template = '{{{foo}}}';

var render = Handlebars.compile(template);
var data = null;
console.log(render(data));
mustache
Data:
null
Template:
{{{foo}}}
Result:
Cannot read property 'foo' of null
Source Code
var Mustache = require('mustache');
var template = '{{{foo}}}';

var data = null;
console.log(Mustache.render(template, data));