declaring client side templates in gtpl files

15 views
Skip to first unread message

Fábio Uechi

unread,
Mar 23, 2012, 1:48:24 PM3/23/12
to gae...@googlegroups.com
Hi,

Most javascript template engine libraries uses a gtpl similar notation ( i.e.  <%= %> ,  <% %> , etc ) for template definition.
I want to declare my templates inside script elemens like this:

<script type="text/x-jqote-template" id="activity-template">
<![CDATA[
<article id="<%= this.id %>">
<img src="<%= this.actor.image.url %>" />
<a href="<%= this.actor.url %>" target="_blank"><%= this.actor.displayName %></a>
<div class="content_link"><%= this.object.content %></div>
</article>
]]>
</script>

For obvious reasons I can't declare them inside my gtpl templates so I'm just printing Gstring static variables "stored" in external classes.
Does anyone see any other way to workaround this?
I wanted them to be a part of the view (gtpl) files.

Thanks in advance
Fábio

Fábio Uechi

unread,
Mar 23, 2012, 2:31:32 PM3/23/12
to gae...@googlegroups.com
Sorry to bother guys!
Just solved it by changing the default tag from '%' to '*'.
Now my javascript templates look like this:

<script type="text/x-jqote-template" id="activity-template">
<![CDATA[
<article id="<*= this.id *>">
<img src="<*= this.actor.image.url *>" />
<a href="<*= this.actor.url *>" target="_blank"><*= this.actor.displayName *></a>
<div class="content_link"><*= this.object.content *></div>
</article>
]]>
</script>

And coexist perfectly with gtpl!

cheers
Fábio

Guillaume Laforge

unread,
Mar 23, 2012, 2:36:16 PM3/23/12
to gae...@googlegroups.com
I think you can also escape like this, and it should work: \<%

2012/3/23 Fábio Uechi <fabio...@gmail.com>:

> --
> You've received this message because you've subscribed to the Gaelyk Google
> Group.
> To send an email to the group, please write to: gae...@googlegroups.com
> To unsuscribe from this group: gaelyk+un...@googlegroups.com
> To show more options: http://groups.google.fr/group/gaelyk?hl=en

--
Guillaume Laforge
Groovy Project Manager
SpringSource, a division of VMware

Blog: http://glaforge.appspot.com/
Social: @glaforge / Google+

Reply all
Reply to author
Forward
0 new messages