[prev in list] [next in list] [prev in thread] [next in thread]
List: groovy-user
Subject: Re: [groovy-user] Re: SimpleTemplateEngine: How to preserve $strings in template
From: Raffaele Sgarro <raffaelesgarro () gmail ! com>
Date: 2013-09-25 14:41:36
Message-ID: CAKg=9UUVW=N6FZ8ppN_6TJGTfLoj9ASXyOnASh7cEznKLB5kAg () mail ! gmail ! com
[Download RAW message or body]
Sorry, there was a typo. Should be <%=REQ_BIND%>
Working on ideone: http://ideone.com/Dh12hc
2013/9/25 Raffaele Sgarro <raffaelesgarro@gmail.com>
> Less contrived
>
> "I'd like this <%REQ_BIND%> but to leave ${'thisone'} alone"
>
>
> 2013/9/25 mj454 <matt.jax@gmail.com>
>
> > Thanks for all the input and prompt responses guys.
> >
> > Paulk - very neat. Will let you know once I've understood exactly what
> > you've done there :-)
> >
> > Also, as this is basically just string substitution (and I'm not worried
> > about performance here), this function works a treat too:
> >
> > def parseTemplate(template, bindings) {
> >
> > String parsedTemplate = template
> > bindings.each() {
> > key, value ->
> > parsedTemplate = parsedTemplate.replace("<%" + key + "%>", value)
> > }
> > return parsedTemplate
> > }
> >
> >
> >
> > --
> > View this message in context:
> > http://groovy.329449.n5.nabble.com/SimpleTemplateEngine-How-to-preserve-strings-in-template-tp5717067p5717072.html
> > Sent from the groovy - user mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> > http://xircles.codehaus.org/manage_email
> >
> >
> >
>
[Attachment #3 (text/html)]
<div dir="ltr">Sorry, there was a typo. Should be <%=REQ_BIND%><div>Working on \
ideone: <a href="http://ideone.com/Dh12hc">http://ideone.com/Dh12hc</a></div></div><div \
class="gmail_extra"><br><br><div class="gmail_quote"> 2013/9/25 Raffaele Sgarro <span \
dir="ltr"><<a href="mailto:raffaelesgarro@gmail.com" \
target="_blank">raffaelesgarro@gmail.com</a>></span><br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> <div dir="ltr">Less contrived<div><br></div><div><span \
style="color:rgb(170,34,34);font-family:Consolas,Monaco,'Bitstream Vera Sans \
Mono','Courier \
New',Courier,monospace;font-size:16px;line-height:19.1875px;background-color:rgb(250,250,250)">"I'd \
like this <%REQ_BIND%> but to leave ${'thisone'} alone"</span><br>
</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div \
class="gmail_quote">2013/9/25 mj454 <span dir="ltr"><<a \
href="mailto:matt.jax@gmail.com" \
target="_blank">matt.jax@gmail.com</a>></span><br> <blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Thanks for all \
the input and prompt responses guys.<br> <br>
Paulk - very neat. Will let you know once I've understood exactly what<br>
you've done there :-)<br>
<br>
Also, as this is basically just string substitution (and I'm not worried<br>
about performance here), this function works a treat too:<br>
<br>
def parseTemplate(template, bindings) {<br>
<br>
String parsedTemplate = template<br>
bindings.each() {<br>
key, value -><br>
parsedTemplate = parsedTemplate.replace("<%" + key + \
"%>", value)<br> }<br>
return parsedTemplate<br>
}<br>
<br>
<br>
<br>
--<br>
View this message in context: <a \
href="http://groovy.329449.n5.nabble.com/SimpleTemplateEngine-How-to-preserve-strings-in-template-tp5717067p5717072.html" \
target="_blank">http://groovy.329449.n5.nabble.com/SimpleTemplateEngine-How-to-preserve-strings-in-template-tp5717067p5717072.html</a><br>
<div><div>Sent from the groovy - user mailing list archive at Nabble.com.<br>
<br>
---------------------------------------------------------------------<br>
To unsubscribe from this list, please visit:<br>
<br>
<a href="http://xircles.codehaus.org/manage_email" \
target="_blank">http://xircles.codehaus.org/manage_email</a><br> <br>
<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic