From ee9df31b175e374e2dbcd4b387a6194704f193a1 Mon Sep 17 00:00:00 2001 From: Michael Wolf Date: Tue, 8 Feb 2011 15:58:39 -0600 Subject: [PATCH] point out that you can use print() inside of js code inside of templates --- index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.html b/index.html index 74dc362c7..bceac282c 100644 --- a/index.html +++ b/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>" +

+ You can also use print from within JavaScript code. This is + sometimes more convenient than using <%= ... %>. +

+ +
+var compiled = _.template("<% print('Hello ' + epithet); %>");
+compiled({epithet: "dude"});
+=> "Hello dude."
+

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.