addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [javascript-12] underscore.js templates

From: Janos M.
Sent on: Thursday, April 12, 2012 3:09 PM
The people I work with will have a heart attack if the syntax is not
JSP/ERB: <% %>
This is why I wanted to keep the original format. However, I can load
the template with a GET if embedding it is not possible without
changing the syntax.

On Thu, Apr 12, 2012 at 3:00 PM, Rory OConnell <[address removed]> wrote:
> 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])
>
>
>
>
>
>
>
> --
> Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
> http://www.meetup...­
> This message was sent by Rory OConnell ([address removed]) from BayJax - The Bay Area Ajax and JavaScript Meetup.
> To learn more about Rory OConnell, 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]
>

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