addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [javascript-12] underscore.js templates

From: Rory O.
Sent on: Thursday, April 12, 2012 2:58 PM
Tell Underscore to use mustache style interpolation instead of ERB style and you're fine. 

_.templateSettings = { interpolate: /\{\{\=(.+?)\}\}/g, evaluate: /\{\{(.+?)\}\}/g }; 

-- 
Rory O'Connell


On Thursday, April 12, 2012 at 2:54 PM, Janos Mucsi wrote:

> Thanks but the problem is that the templating engine (ERB) will try to
> process the microtemplate and emit errors.
> 
> On Thu, Apr 12, 2012 at 2:27 PM, alex kessinger <[address removed] (mailto:[address removed])> wrote:
> > http://ejohn.org/...­
> > 
> > On Thu, Apr 12, 2012 at 2:17 PM, Janos Mucsi
> > <[address removed] (mailto:[address removed])> wrote:
> > > Hi,
> > > 
> > > I need to embed an underscore.js template in an ERB or JSP. It uses
> > > the <% %> syntax which I want to preserve (anybody has to be able to
> > > edit the template).
> > > What's the best way to embed the template so I can retrieve it with
> > > jQuery for processing?
> > > Any ideas?
> > > 
> > > One solution is to add this line in the ERB referencing the template
> > > file. This avoids the processing of the <% %> tags:
> > > 
> > > <div id="template1"><­%=
> > > File.read(File.dirna­me(__FILE__)+"/templ­.file") %></div>
> > > 
> > > If I don't want to dynamically load the template (through Ajax), what
> > > is an other solution?
> > > 
> > > Thanks.
> > > 
> > > Janos
> > > 
> > > 
> > > 
> > > --
> > > Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed] (mailto:[address removed]))
> > > http://www.meetup...­
> > > This message was sent by Janos Mucsi ([address removed] (mailto:[address removed])) from BayJax - The Bay Area Ajax and JavaScript Meetup.
> > > To learn more about Janos Mucsi, visit his/her member profile: http://www.meetup...­
> > > Set my mailing list to email me
> > > 
> > > As they are sent
> > > http://www.meetup...­
> > > 
> > > In one daily email
> > > http://www.meetup...­
> > > 
> > > Don't send me mailing list messages
> > > http://www.meetup...­
> > > Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed] (mailto:[address removed])
> > 
> > 
> > 
> > 
> > 
> > --
> > Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed] (mailto:[address removed]))
> > http://www.meetup...­
> > This message was sent by alex kessinger ([address removed] (mailto:[address removed])) from BayJax - The Bay Area Ajax and JavaScript Meetup.
> > To learn more about alex kessinger, visit his/her member profile: http://www.meetup...­
> > Set my mailing list to email me
> > 
> > As they are sent
> > http://www.meetup...­
> > 
> > In one daily email
> > http://www.meetup...­
> > 
> > Don't send me mailing list messages
> > http://www.meetup...­
> > Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed] (mailto:[address removed])
> 
> 
> 
> 
> 
> --
> Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed] (mailto:[address removed]))
> http://www.meetup...­
> This message was sent by Janos Mucsi ([address removed] (mailto:[address removed])) from BayJax - The Bay Area Ajax and JavaScript Meetup.
> To learn more about Janos Mucsi, visit his/her member profile: http://www.meetup...­
> Set my mailing list to email me
> 
> As they are sent
> http://www.meetup...­
> 
> In one daily email
> http://www.meetup...­
> 
> Don't send me mailing list messages
> http://www.meetup...­
> Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed] (mailto:[address removed])



People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy