[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 &lt;%=REQ_BIND%&gt;<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">&lt;<a href="mailto:raffaelesgarro@gmail.com" \
target="_blank">raffaelesgarro@gmail.com</a>&gt;</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,&#39;Bitstream Vera Sans \
Mono&#39;,&#39;Courier \
New&#39;,Courier,monospace;font-size:16px;line-height:19.1875px;background-color:rgb(250,250,250)">&quot;I&#39;d \
like this &lt;%REQ_BIND%&gt; but to leave ${&#39;thisone&#39;} alone&quot;</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">&lt;<a \
href="mailto:matt.jax@gmail.com" \
target="_blank">matt.jax@gmail.com</a>&gt;</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&#39;ve understood exactly what<br>
you&#39;ve done there :-)<br>
<br>
Also, as this is basically just string substitution (and I&#39;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 -&gt;<br>
      parsedTemplate = parsedTemplate.replace(&quot;&lt;%&quot; + key + \
&quot;%&gt;&quot;, 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