By default the line change for standalone tags will be removed. If you wanna remove more line changes or spaces, you can use ~
in left or right side of a tag.
This is a handlebars.js extension, mustache do not support this.
array(
"foo" => 1
)
Line 1
Line 3
Line 5
Line 7
Line 1
1
Line 3
1
Line 5
1
Line 7
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "Line 1\n{{foo}}\nLine 3\n {{foo}}\nLine 5\n {{foo}}\nLine 7\n";
$php = LightnCandy::compile($template);
$render = LightnCandy::prepare($php);
$data = array(
"foo" => 1
);
echo $render($data);
{
"foo": 1
}
Line 1
Line 3
Line 5
Line 7
Line 1
1
Line 3
1
Line 5
1
Line 7
var Handlebars = require('handlebars');
var template = 'Line 1\n{{foo}}\nLine 3\n {{foo}}\nLine 5\n {{foo}}\nLine 7\n';
var render = Handlebars.compile(template);
var data = {
"foo": 1
};
console.log(render(data));
{{else}}
will be removedUsed option: FLAG_THIS FLAG_ELSE
array(
"foo" => 1
)
Line 1
Line 3
Line 5
Line 7
Line 1
Line 3
Line 7
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "Line 1\n{{#with foo}}\nLine 3\n{{else}}\nLine 5\n{{/with}}\nLine 7\n";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_THIS | LightnCandy::FLAG_ELSE
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => 1
);
echo $render($data);
{
"foo": 1
}
Line 1
Line 3
Line 5
Line 7
Line 1
Line 3
Line 7
var Handlebars = require('handlebars');
var template = 'Line 1\n{{#with foo}}\nLine 3\n{{else}}\nLine 5\n{{/with}}\nLine 7\n';
var render = Handlebars.compile(template);
var data = {
"foo": 1
};
console.log(render(data));
Used option: FLAG_THIS FLAG_ELSE
array(
"foo" => 1
)
Line 1
Line 3
Line 5
Line 7
Line 1
1Line 31Line 51
Line 7
require('./vendor/autoload.php');
use LightnCandy\LightnCandy;
$template = "Line 1\n{{foo~}}\nLine 3\n {{~foo~}}\nLine 5\n {{~foo}}\nLine 7\n";
$php = LightnCandy::compile($template, array(
"flags" => LightnCandy::FLAG_THIS | LightnCandy::FLAG_ELSE
));
$render = LightnCandy::prepare($php);
$data = array(
"foo" => 1
);
echo $render($data);
{
"foo": 1
}
Line 1
Line 3
Line 5
Line 7
Line 1
1Line 31Line 51
Line 7
var Handlebars = require('handlebars');
var template = 'Line 1\n{{foo~}}\nLine 3\n {{~foo~}}\nLine 5\n {{~foo}}\nLine 7\n';
var render = Handlebars.compile(template);
var data = {
"foo": 1
};
console.log(render(data));