{"id":1778,"date":"2010-10-01T21:22:32","date_gmt":"2010-10-01T15:52:32","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1778"},"modified":"2016-12-19T15:16:58","modified_gmt":"2016-12-19T09:46:58","slug":"grails-the-tmpl-namespace-for-rendering-the-gsp-templates","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/grails-the-tmpl-namespace-for-rendering-the-gsp-templates\/","title":{"rendered":"Grails way for rendering the GSP templates: The tmpl namespace."},"content":{"rendered":"<p>Today while working on a project, I paired up with my colleague (<a href=\"http:\/\/www.tothenew.com\/blog\/author\/uday\">Uday<\/a>)\u00a0 and we found that we can render a gsp template in a different manner also. Grails provide us a <strong>&#8220;tmpl&#8221; namespace<\/strong> for rendering the GSP templates.<br \/>\n<br \/>\nThe old way that we use to render a gsp template<\/p>\n<pre lang=\"groovy\">\r\n<g:render template=\"templateName\" model=\"[books:books, authors:authors]\"\/>\r\n<\/pre>\n<p>The other way for\u00a0 rendering the template.<\/p>\n<pre lang=\"groovy\">\r\n<tmpl:templateName books=${books}\u00a0 authors=\"${authors}\"\/>\r\n<\/pre>\n<p>Like me, you also must be wondering that if the template is in some other path like some shared folder <strong>&#8220;\/shared\/templateName&#8221;<\/strong> then how this &lt;tmpl\/&gt; would work?<\/p>\n<p>e.g.<\/p>\n<pre lang=\"groovy\">\r\n<g:render template=\"\/shared\/templateName\" model=\"[books:books, authors:authors]\"\/>\r\n<\/pre>\n<p>The answer is: &lt;tmpl:\/shared\/templateName\/&gt;<\/p>\n<pre lang=\"groovy\">\r\n<tmpl:\/shared\/templateName books=${books}\u00a0 authors=\"${authors}\"\/>\r\n<\/pre>\n<p>* you can find the documentation for this on <a href=\"http:\/\/www.grails.org\/doc\/latest\/guide\/single.html\">http:\/\/www.grails.org\/doc\/latest\/guide\/single.html<\/a><br \/>\n<br \/>\nConcerns, comments or suggestions are always welcome.<br \/>\nCheers!!!!!<br \/>\n~Chandan Luthra~<br \/>\nchandan(aT)intelligrape(dOt)com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today while working on a project, I paired up with my colleague (Uday)\u00a0 and we found that we can render a gsp template in a different manner also. Grails provide us a &#8220;tmpl&#8221; namespace for rendering the GSP templates. The old way that we use to render a gsp template The other way for\u00a0 rendering [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":7},"categories":[7],"tags":[4840,9,32],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1778"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1778"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1778\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}