Comment

A comment begin with! and will be ignored. For example: {{! this is a comment}}

Samples


lightncandy
Data:
array(
  "foo" => "OK"
)
Template:
{{#foo}}Ya!{{! ignored this comment}}{{/foo}}
Result:
Ya!
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{#foo}}Ya!{{! ignored this comment}}{{/foo}}";

$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
  "foo" => "OK"
);
echo $render($data);
handlebars.js
Data:
{
  "foo": "OK"
}
Template:
{{#foo}}Ya!{{! ignored this comment}}{{/foo}}
Result:
Ya!
Source Code
var Handlebars = require('handlebars');
var template = '{{#foo}}Ya!{{! ignored this comment}}{{/foo}}';

var render = Handlebars.compile(template);
var data = {
  "foo": "OK"
};
console.log(render(data));
mustache
Data:
{
  "foo": "OK"
}
Template:
{{#foo}}Ya!{{! ignored this comment}}{{/foo}}
Result:
Ya!
Source Code
var Mustache = require('mustache');
var template = '{{#foo}}Ya!{{! ignored this comment}}{{/foo}}';

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

lightncandy
Data:
array(
  "foo" => true
)
Template:
{{#foo}}Yes{{! foo is true}}{{/foo}}
{{^foo}}No{{! foo is false}}{{/foo}}
Result:
Yes
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "{{#foo}}Yes{{! foo is true}}{{/foo}}\n{{^foo}}No{{! foo is false}}{{/foo}}";

$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
  "foo" => true
);
echo $render($data);
handlebars.js
Data:
{
  "foo": true
}
Template:
{{#foo}}Yes{{! foo is true}}{{/foo}}
{{^foo}}No{{! foo is false}}{{/foo}}
Result:
Yes
Source Code
var Handlebars = require('handlebars');
var template = '{{#foo}}Yes{{! foo is true}}{{/foo}}\n{{^foo}}No{{! foo is false}}{{/foo}}';

var render = Handlebars.compile(template);
var data = {
  "foo": true
};
console.log(render(data));
mustache
Data:
{
  "foo": true
}
Template:
{{#foo}}Yes{{! foo is true}}{{/foo}}
{{^foo}}No{{! foo is false}}{{/foo}}
Result:
Yes
Source Code
var Mustache = require('mustache');
var template = '{{#foo}}Yes{{! foo is true}}{{/foo}}\n{{^foo}}No{{! foo is false}}{{/foo}}';

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

}} can not be placed inside a comment.

lightncandy
Data:
NULL
Template:
Comment example: {{! comment with }} is not ok }}
Result:
Comment example:  is not ok }}
Source Code
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "Comment example: {{! comment with }} is not ok }}";

$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = NULL;
echo $render($data);
handlebars.js
Data:
Template:
Comment example: {{! comment with }} is not ok }}
Result:
Comment example:  is not ok }}
Source Code
var Handlebars = require('handlebars');
var template = 'Comment example: {{! comment with }} is not ok }}';

var render = Handlebars.compile(template);
var data = undefined;
console.log(render(data));
mustache
Data:
Template:
Comment example: {{! comment with }} is not ok }}
Result:
Comment example:  is not ok }}
Source Code
var Mustache = require('mustache');
var template = 'Comment example: {{! comment with }} is not ok }}';

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

See Also...