title: Grails: Rendering template from taglib as HTML
body: <p>I'm trying to render my template from taglib:</p>
  
  <pre><code>out &lt;&lt; g.render(template: "/menu/sidebar")
  </code></pre>
  
  <p>This is what my sidebar template looks like:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;TEST1&lt;/li&gt;
      &lt;li&gt;TEST2&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>When I inspect my page in browser, whole template code appears in apostrophes like this...</p>
  
  <pre><code>"&lt;ul&gt;
      &lt;li&gt;TEST1&lt;/li&gt;
      &lt;li&gt;TEST2&lt;/li&gt;
  &lt;/ul&gt;"
  </code></pre>
  
  <p>...and prints my html code just like a plain text. Any idea how to make it recognize the content as proper html code?</p>
  
  <p><strong>Edit:</strong> Taglib code:</p>
  
  <pre><code>class MenuTagLib {
      static defaultEncodeAs = 'html'
      def renderIfExists = { attrs,body-&gt;
          GrailsConventionGroovyPageLocator groovyPageLocator
          println attrs.template
          if(groovyPageLocator.findTemplateByPath(attrs.template))
          {
              g.render(template:attrs.template)
          }
          else{   
  
  
              out &lt;&lt; g.render(template: "/menu/sidebar")
          }
      }
  }
  </code></pre>
  
  <p>The way of calling it:</p>
  
  <pre><code>&lt;g:renderIfExists template="/${params.controller}/sidebar" plugin="untitled1" /&gt;
  </code></pre>