groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Danny Hyun <hyun.da...@gmail.com>
Subject Re: Bug in MarkupTemplateEngine?
Date Fri, 20 Nov 2015 14:12:06 GMT
Hi Esteben,

I don't know if this is a bug or not but to make your assertion pass I've
made the following change to the template:


import groovy.text.markup.MarkupTemplateEngine
import java.io.StringWriter
def eng = new MarkupTemplateEngine()

def w = new StringWriter()
eng.createTemplate ('''
n1{ yield 'text1' n2('text2') }
''').make().writeTo(w)

assert w.toString() == '<n1>text1<n2>text2</n2></n1>'

You can make use of yield and yieldUnescaped to create text nodes
More info
http://www.groovy-lang.org/templating.html#_the_markuptemplateengine

On Thu, Nov 19, 2015 at 11:47 PM, Esteban GĂ­nez <eginez@gmail.com> wrote:

> Hey guys
>
> I've been playing with the MarkupTemplateEngine these past few days, I
> wanted to use it in lieu of gsp..(no offense to gsp's but the groovy
> templates are way nicer).
>
> As a first step I was able to hack a taglib that allows to 'embed' groovy
> templates in your gsp
> like so
> ..some gsp
> <g:gtp>
> h1('some h1 title) { a('some more text') }
> <g:gtp>
> ....contnue gsp
>
> https://gist.github.com/eginez/adaf5a07a6226a7097eb
>
> While doing so I noticed that some interesting rendering...
>
> import groovy.text.markup.MarkupTemplateEngine
> import java.io.StringWriter
> def eng = new MarkupTemplateEngine()
>
> def w = new StringWriter()
> eng.createTemplate ('''
> n1('text1'){ n2('text2') }
> ''').make().writeTo(w)
> assert w.toString() == '<n1>text1<n2>text2</n2></n1>'
>
> The above assertion evaluates to false, the string that gets generated is
> <n1><n2>text2</n2></n1>
>
> Wondering if some has seen this in the past or is a known bug. I haven't
> looked into the code yet but I'll do it a little later
> Any input is appreciated
> Thanks guys
> E.
>
>
>


-- 
Thanks,

Daniel Hyun
blog: http://hyunlabs.com/

Mime
View raw message