live-template

{live-template}

Plugin: Scaffolding Plugin, from version 2.2.x

Imports and renders the current version of a template.

Description

Essentially, this macro takes the text content of a Page Template and render that text in the context of the current page. It doesn't matter if there is are any Scaffolding macros on that template or not, it just renders the text as wiki text. This is different than creating a page with a template as in the built-in system because that will copy-n-paste the text in once, but if you update the template, the page you created with the template will not get updated.

Usage

{live-template:Page Template Name}

Parameters

Name Required Default Description
[default]/name
The name of the page template to import and render.

Examples

You have a set of products and want all the product pages to have a similar structure. Here are the steps:

Create the template
  1. First, create a new Page Template (Browse Space > Advanced > Templates > Add new template)
  2. Then put something like this as the template content:
    h2. {text-data:Title}
    {text-data:Summary|type=area}
    
    *Unit Price:* {number-data:Price|decimal=true}
    *Shipping Cost:* {number-data:Price|decimal=true}
    
  3. Save the template with a name of 'Product Template'
Create the product page
  1. Now, add a new page
  2. As the page contents, put the following:
    {live-template:Product Template}
    
    Note!
    This is the name of the template, not the scaffold!
  3. Save the page (as, for example, 'Widget 1')
  4. Once it's saved, you'll be asked to enter the details for the 'Title', 'Cost' and 'Shipping' fields.
  5. Repeat ad-nausium for all of your products.

Update the original template

After a while, you decide you really want the costs to be listed before the summary. Also, you'd like to specify a release date.

  1. Edit the 'Product Template' template (Browse Space > Advanced > Templates > Edit)
  2. Change the text to the following:
    h2. {text-data:Title}
    *Unit Price:* {number-data:Price|decimal=true}
    *Shipping Cost:* {number-data:Price|decimal=true}
    *Release Date:* {date-data:Release Date|format=d MMM, yyyy}
    
    {text-data:Summary|type=area}
    
  3. Save your changes and check your product pages. You will need to edit them and fill in the release date for each.

Labels

macro macro Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.