Studs Template Taglib

The template tag library provides a mechanism to push data into a common template from the individual phase file being executed. Most developers are more than familiar with the “header/footer” mechanism of generating web pages. There are several problems with that approach, which the template tag library intends to solve. Namely, the content portion of the page is execute first, and is then “plugged into” the template which should have minimal knowledge of the individual page. The template simply accepts what it is given and is thus truly generic and decoupled.

template:insert - Inserts a template into the current page

Property Type EL? Description
template attribute Specifies the relative or absolute (from root of context) path to a PSP template file

Examples:

<template:insert template="/WEB-INF/pages/layout.psp">
  <template:put name="title" content="Example Title" direct="true" />
  <template:put name="body" direct="true">This is the body of our page!</template:put>
  <template:put name="footer" content="/common/footer.psp" />
</template:insert>

template:put - Establishes a variable to be passed to the template

Property Type EL? Description
name attribute The name of the variable to be set and passed to the template
content attribute The content of the variable to be passed to the template
direct attribute Boolean indicating the content is text to be outputted; otherwise, the value is assumed to be an include file
- body Alternate means of providing content for this template variable

Note: Some people get tripped up on this, but the direct attribute means “literal”, whereas the default is to interpret the content as a path to an include file.

template:get - Retrieve the value of a variable in the template

This tag is used inside the template page to retrieve values that were passed in.

Property Type EL? Description
name attribute The name of the variable to retrieve and insert

Examples:

<title><template:get name="title" /></title>
 
reference/studs_template_taglib.txt · Last modified: 2005/09/04 17:30 by 68.50.139.221 (dallen)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki