An inverted block is started with {{^foo}}
and end with {{/foo}}
.
array(
"foo" => array(
1,
3,
5
)
)
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
1,
3,
5
)
);
echo $render($data);
{
"foo": [
1,
3,
5
]
}
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": [
1,
3,
5
]
};
console.log(render(data));
{
"foo": [
1,
3,
5
]
}
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": [
1,
3,
5
]
};
console.log(Mustache.render(template, data));
array(
"foo" => array(
"bar" => NULL,
"moo" => NULL
)
)
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"bar" => NULL,
"moo" => NULL
)
);
echo $render($data);
{
"foo": {
"bar": null,
"moo": null
}
}
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": {
"bar": null,
"moo": null
}
};
console.log(render(data));
{
"foo": {
"bar": null,
"moo": null
}
}
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": {
"bar": null,
"moo": null
}
};
console.log(Mustache.render(template, data));
array(
"foo" => "test"
)
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => "test"
);
echo $render($data);
{
"foo": "test"
}
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": "test"
};
console.log(render(data));
{
"foo": "test"
}
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": "test"
};
console.log(Mustache.render(template, data));
array(
"foo" => 1
)
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => 1
);
echo $render($data);
{
"foo": 1
}
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": 1
};
console.log(render(data));
{
"foo": 1
}
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": 1
};
console.log(Mustache.render(template, data));
false
, the inner content will be rendered.array(
"foo" => false
)
Ya!
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => false
);
echo $render($data);
{
"foo": false
}
Ya!
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": false
};
console.log(render(data));
{
"foo": false
}
Ya!
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": false
};
console.log(Mustache.render(template, data));
empty array
, the inner content will be rendered.array(
"foo" => array(
)
)
Ya!
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
)
);
echo $render($data);
{
"foo": []
}
Ya!
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": []
};
console.log(render(data));
{
"foo": []
}
Ya!
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": []
};
console.log(Mustache.render(template, data));
null
or undefined
, the inner content will be rendered.array(
"foo" => NULL
)
Ya!
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => NULL
);
echo $render($data);
{
"foo": null
}
Ya!
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": null
};
console.log(render(data));
{
"foo": null
}
Ya!
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": null
};
console.log(Mustache.render(template, data));
0
is false
.array(
"foo" => 0
)
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => 0
);
echo $render($data);
{
"foo": 0
}
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": 0
};
console.log(render(data));
{
"foo": 0
}
Ya!
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": 0
};
console.log(Mustache.render(template, data));
false
.array(
"foo" => ""
)
Ya!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}Ya!{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => ""
);
echo $render($data);
{
"foo": ""
}
Ya!
var Handlebars = require('handlebars');
var template = '{{^foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": ""
};
console.log(render(data));
{
"foo": ""
}
Ya!
Ya!
var Mustache = require('mustache');
var template = '{{^foo}}Ya!{{/foo}}';
var data = {
"foo": ""
};
console.log(Mustache.render(template, data));
Used option: FLAG_JSTRUE
array(
"foo" => false,
"bar" => "Good!"
)
,
false,Good!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}{{foo}},{{bar}}{{/foo}}\n";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSTRUE
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => false,
"bar" => "Good!"
);
echo $render($data);
{
"foo": false,
"bar": "Good!"
}
,
false,Good!
var Handlebars = require('handlebars');
var template = '{{^foo}}{{foo}},{{bar}}{{/foo}}\n';
var render = Handlebars.compile(template);
var data = {
"foo": false,
"bar": "Good!"
};
console.log(render(data));
{
"foo": false,
"bar": "Good!"
}
,
false,Good!
var Mustache = require('mustache');
var template = '{{^foo}}{{foo}},{{bar}}{{/foo}}\n';
var data = {
"foo": false,
"bar": "Good!"
};
console.log(Mustache.render(template, data));
array(
"foo" => false,
"bar" => false,
"moo" => "OH!"
)
OH!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{^foo}}{{^bar}}{{moo}}{{/bar}}{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => false,
"bar" => false,
"moo" => "OH!"
);
echo $render($data);
{
"foo": false,
"bar": false,
"moo": "OH!"
}
OH!
var Handlebars = require('handlebars');
var template = '{{^foo}}{{^bar}}{{moo}}{{/bar}}{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": false,
"bar": false,
"moo": "OH!"
};
console.log(render(data));
{
"foo": false,
"bar": false,
"moo": "OH!"
}
OH!
var Mustache = require('mustache');
var template = '{{^foo}}{{^bar}}{{moo}}{{/bar}}{{/foo}}';
var data = {
"foo": false,
"bar": false,
"moo": "OH!"
};
console.log(Mustache.render(template, data));