mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Add template and settings build options unit tests and tweak _.template docs.
Former-commit-id: c814799c82e5a1dde60e5eda4dda5cb192d437f9
This commit is contained in:
@@ -2527,7 +2527,7 @@ var compiled = _.template('hello: <%= name %>');
|
||||
compiled({ 'name': 'moe' });
|
||||
// => 'hello: moe'
|
||||
|
||||
var list = '<% _.forEach(people, function(name) { %> <li><%= name %></li> <% }); %>';
|
||||
var list = '<% _.forEach(people, function(name) { %><li><%= name %></li><% }); %>';
|
||||
_.template(list, { 'people': ['moe', 'larry', 'curly'] });
|
||||
// => '<li>moe</li><li>larry</li><li>curly</li>'
|
||||
|
||||
@@ -2536,12 +2536,12 @@ _.template('<b><%- value %></b>', { 'value': '<script>' });
|
||||
// => '<b><script></b>'
|
||||
|
||||
// using the internal `print` function in "evaluate" delimiters
|
||||
_.template('<% print("Hello " + epithet); %>', { 'epithet': 'stooge' });
|
||||
_.template('<% print("Hello " + epithet); %>.', { 'epithet': 'stooge' });
|
||||
// => 'Hello stooge.'
|
||||
|
||||
// using custom template delimiter settings
|
||||
_.templateSettings = {
|
||||
'interpolate': /\{\{(.+?)\}\}/g
|
||||
'interpolate': /\{\{([\s\S]+?)\}\}/g
|
||||
};
|
||||
|
||||
_.template('Hello {{ name }}!', { 'name': 'Mustache' });
|
||||
|
||||
Reference in New Issue
Block a user