I'm trying to render my template from taglib:
out << g.render(template: "/menu/sidebar")
This is what my sidebar template looks like:
<ul>
<li>TEST1</li>
<li>TEST2</li>
</ul>
When I inspect my page in browser, whole template code appears in apostrophes like this...
"<ul>
<li>TEST1</li>
<li>TEST2</li>
</ul>"
...and prints my html code just like a plain text. Any idea how to make it recognize the content as proper html code?
Edit: Taglib code:
class MenuTagLib {
static defaultEncodeAs = 'html'
def renderIfExists = { attrs,body->
GrailsConventionGroovyPageLocator groovyPageLocator
println attrs.template
if(groovyPageLocator.findTemplateByPath(attrs.template))
{
g.render(template:attrs.template)
}
else{
out << g.render(template: "/menu/sidebar")
}
}
}
The way of calling it:
<g:renderIfExists template="/${params.controller}/sidebar" plugin="untitled1" />
If I had to guess, it would be that you have this in your class:
static defaultEncodeAs = 'html'
You should remove that line and try it again. That says that it should escape html characters.