Thursday, 15 August 2013

Grails GSP outer templates with inner content? -


Is Grails a way to change the following in GSP

  < Tmpl: / Template / Header / & gt; & Lt ;! - tmpl namespace call & lt; G is equal to: template = "/ templates / header" /> Render - & gt; & Lt ;! - Definition of internal content - & gt; & Lt; Tmpl: / template / clergy / & gt;   

with external template? Basically, a way to import wrapping exterior template,

  & lt; Outertemplate: templatename & gt; & Lt ;! - Header will be sung from the external template - & gt; & Lt ;! - Definition of internal content - & gt; & Lt ;! - Footer will be provided from external template - & gt; & Lt; / Outertemplate: TEMPLATENAME & gt;   

and the definition of an external template

    

Capturing two templates versus wrapping content in a single template. IIRC was there a way to do this under JSF, but I could not find any equivalent under GSP.

You can create something like using the tag library.

  class SimpleTagLib {def emoticon = {attrs, body - & gt; Outside & lt; & Lt; Body () & lt; & Lt; (Attrs.happy == 'true'? ":-)": ":: :-("}}}   

This defines a tag emoticon Which may be used in GSP such as:

  & lt; G: emoticon happy = "true" & gt; Hi John & lt; / G: emoticon & gt;   

body () is used to render tags body content.

(example is copied from official)

No comments:

Post a Comment