A block is started with {{#foo}}
and end with {{/foo}}
.
array(
"foo" => array(
1,
3,
5
)
)
Ya!
Ya!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(
1,
3,
5
)
);
echo $render($data);
{
"foo": [
1,
3,
5
]
}
Ya!
Ya!Ya!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!
Ya!Ya!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!
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!
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!
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!
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!
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!
Ya!
var Mustache = require('mustache');
var template = '{{#foo}}Ya!{{/foo}}';
var data = {
"foo": "test"
};
console.log(Mustache.render(template, data));
array(
"foo" => 1
)
Ya!
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!
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!
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 not be rendered.array(
"foo" => false
)
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!
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!
var Mustache = require('mustache');
var template = '{{#foo}}Ya!{{/foo}}';
var data = {
"foo": false
};
console.log(Mustache.render(template, data));
null
or undefined
, the inner content will not be rendered.array(
"foo" => NULL
)
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!
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!
var Mustache = require('mustache');
var template = '{{#foo}}Ya!{{/foo}}';
var data = {
"foo": null
};
console.log(Mustache.render(template, data));
false
.array(
"foo" => array(
)
)
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!
var Handlebars = require('handlebars');
var template = '{{#foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": []
};
console.log(render(data));
{
"foo": []
}
Ya!
var Mustache = require('mustache');
var template = '{{#foo}}Ya!{{/foo}}';
var data = {
"foo": []
};
console.log(Mustache.render(template, data));
0
as false
.array(
"foo" => 0
)
Ya!
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!
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!
var Mustache = require('mustache');
var template = '{{#foo}}Ya!{{/foo}}';
var data = {
"foo": 0
};
console.log(Mustache.render(template, data));
false
.array(
"foo" => ""
)
Ya!
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!
Ya!
var Handlebars = require('handlebars');
var template = '{{#foo}}Ya!{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": ""
};
console.log(render(data));
{
"foo": ""
}
Ya!
var Mustache = require('mustache');
var template = '{{#foo}}Ya!{{/foo}}';
var data = {
"foo": ""
};
console.log(Mustache.render(template, data));
Used option: FLAG_JSOBJECT
array(
"foo" => array(
"foo" => "Hello",
"bar" => "World"
),
"bar" => "OK"
)
,
,
[object Object],OK
Hello,World
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{foo}},{{bar}}\n{{#foo}}{{foo}},{{bar}}{{/foo}}\n";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_JSOBJECT
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"foo" => "Hello",
"bar" => "World"
),
"bar" => "OK"
);
echo $render($data);
{
"foo": {
"foo": "Hello",
"bar": "World"
},
"bar": "OK"
}
,
,
[object Object],OK
Hello,World
var Handlebars = require('handlebars');
var template = '{{foo}},{{bar}}\n{{#foo}}{{foo}},{{bar}}{{/foo}}\n';
var render = Handlebars.compile(template);
var data = {
"foo": {
"foo": "Hello",
"bar": "World"
},
"bar": "OK"
};
console.log(render(data));
{
"foo": {
"foo": "Hello",
"bar": "World"
},
"bar": "OK"
}
,
,
[object Object],OK
Hello,World
var Mustache = require('mustache');
var template = '{{foo}},{{bar}}\n{{#foo}}{{foo}},{{bar}}{{/foo}}\n';
var data = {
"foo": {
"foo": "Hello",
"bar": "World"
},
"bar": "OK"
};
console.log(Mustache.render(template, data));
array(
"foo" => array(
"bar" => array(
"moo" => "MOO!"
)
)
)
MOO!
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{#foo}}{{#bar}}{{moo}}{{/bar}}{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
"bar" => array(
"moo" => "MOO!"
)
)
);
echo $render($data);
{
"foo": {
"bar": {
"moo": "MOO!"
}
}
}
MOO!
var Handlebars = require('handlebars');
var template = '{{#foo}}{{#bar}}{{moo}}{{/bar}}{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": {
"bar": {
"moo": "MOO!"
}
}
};
console.log(render(data));
{
"foo": {
"bar": {
"moo": "MOO!"
}
}
}
MOO!
var Mustache = require('mustache');
var template = '{{#foo}}{{#bar}}{{moo}}{{/bar}}{{/foo}}';
var data = {
"foo": {
"bar": {
"moo": "MOO!"
}
}
};
console.log(Mustache.render(template, data));
array(
"foo" => array(
array(
"bar" => "Yes, "
),
array(
"bar" => "hello "
),
array(
"bar" => "world."
)
)
)
Yes, hello world.
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{#foo}}{{bar}}{{/foo}}";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => array(
array(
"bar" => "Yes, "
),
array(
"bar" => "hello "
),
array(
"bar" => "world."
)
)
);
echo $render($data);
{
"foo": [
{
"bar": "Yes, "
},
{
"bar": "hello "
},
{
"bar": "world."
}
]
}
Yes, hello world.
var Handlebars = require('handlebars');
var template = '{{#foo}}{{bar}}{{/foo}}';
var render = Handlebars.compile(template);
var data = {
"foo": [
{
"bar": "Yes, "
},
{
"bar": "hello "
},
{
"bar": "world."
}
]
};
console.log(render(data));
{
"foo": [
{
"bar": "Yes, "
},
{
"bar": "hello "
},
{
"bar": "world."
}
]
}
Yes, hello world.
var Mustache = require('mustache');
var template = '{{#foo}}{{bar}}{{/foo}}';
var data = {
"foo": [
{
"bar": "Yes, "
},
{
"bar": "hello "
},
{
"bar": "world."
}
]
};
console.log(Mustache.render(template, data));