"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Tags/pageProperty.html" (14 Sep 2022, 66184 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)

pageProperty

Purpose

Used in layouts to output the contents of a property of the decorated page. Equivalent to the SiteMesh <decorator:getProperty/> tag.

Examples

Example decorated page:

<html>
   <head>
        <meta name="layout" content="myLayout" />
        <script src="myscript.js" />
   </head>
   <body onload="alert('hello');">Page to be decorated</body>
</html>

Example decorator layout:

<html>
   <head>
        <script src="global.js" />
        <g:layoutHead />
   </head>
   <body onload="${pageProperty(name:'body.onload')}"><g:layoutBody /></body>
</html>

Results in:

<html>
   <head>
        <script src="global.js" />
        <script src="myscript.js" />
   </head>
   <body onload="alert('hello');">Page to be decorated</body>
</html>

Another example with more options used is below:

We have a layout gsp file container.gsp

<section>
    <header>
        <g:pageProperty name="page.title"/>
    </header>

    <section>
        <g:layoutBody />
    </section>
</section>

The layout is applied to a sub-part of the gsp file using applyLayout tag.

<html>
<head>
    <title>Title 1</title>
</head>

<body>
   <section class="major-part left-part">
      <g:applyLayout name="container">
         <content tag="title">
            Title 2
         </content>
         Some other things
      </g:applyLayout>
   </section>
</body>
</html>

This will result in the below page.

<html>
<head>
    <title>Title 1</title>
</head>

<body>
   <section class="major-part left-part">
      <section>
         <header>
            Title 2
         </header>

         <section>
            Some other things
         </section>
      </section>
   </section>
</body>
</html>

Notice how "Title 2" from the content tag was picked via page.title and the rest was picked up by <g:layoutBody />. You can have any number of such content tags with different tag values (e.g. tag="grails") and then use them in your layouts via the pageProperty tag.

Description

Attributes

  • name (required) - The property name

  • default (optional) - The default value to use if the property is null. (defaults to null)

  • writeEntireProperty (optional) - If true, writes the property in the form 'foo = "bar"', otherwise renders 'bar'. (defaults to false)