mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
point out that you can use print() inside of js code inside of templates
This commit is contained in:
10
index.html
10
index.html
@@ -1097,6 +1097,16 @@ var list = "<% _.each(people, function(name) { %> <li><%= name %&
|
||||
_.template(list, {people : ['moe', 'curly', 'larry']});
|
||||
=> "<li>moe</li><li>curly</li><li>larry</li>"</pre>
|
||||
|
||||
<p>
|
||||
You can also use <tt>print</tt> from within JavaScript code. This is
|
||||
sometimes more convenient than using <tt><%= ... %></tt>.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
var compiled = _.template("<% print('Hello ' + epithet); %>");
|
||||
compiled({epithet: "dude"});
|
||||
=> "Hello dude."</pre>
|
||||
|
||||
<p>
|
||||
If ERB-style delimiters aren't your cup of tea, you can change Underscore's
|
||||
template settings to use different symbols to set off interpolated code.
|
||||
|
||||
Reference in New Issue
Block a user