Open return-com opened 5 years ago
Handlebar.js
Handlebars.registerHelper('customHelper', function(options) { // your custom logic here });
var template = Handlebars.compile("Hello, {{name}}!"); // Default // Change delimiters Handlebars.templates['my-template'] = Handlebars.compile("Hello, [[name]]!", { delimeters: ['[[', ']]'] });
var Mustache = require('mustache');
var template = "Hello, {{{name}}}!"; var output = Mustache.render(template, { name: "World" });
// Mustache does not support custom delimiters directly. You need to preprocess the template text.
const ejs = require('ejs');
const template = "
from jinja2 import Environment, FileSystemLoader
env = Environment( loader=FileSystemLoader('templates'), block_start_string='[%', block_end_string='%]', variable_start_string='[[', variable_end_string=']]' )
template = env.get_template('template.html') output = template.render(name="World")
$twig->setDelimiters(array( 'tag_comment' => array('{#', '#}'), 'tag_block' => array('{%', '%}'), 'tag_variable' => array('{{', '}}'), ));
Liquid::Template.register_filter(MyCustomFilter)
The replacement symbol of template engine {{ and }} conflicts with the template engine of other frameworks. What can you do about it?