Add template and settings build options unit tests and tweak _.template docs.

Former-commit-id: c814799c82e5a1dde60e5eda4dda5cb192d437f9
This commit is contained in:
John-David Dalton
2012-09-30 01:03:43 -07:00
parent 463b5c6e49
commit de821e55ae
4 changed files with 100 additions and 50 deletions

View File

@@ -3685,7 +3685,7 @@
* 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>'
*
@@ -3694,12 +3694,12 @@
* // => '<b>&lt;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' });