Go to main content

Yield

On this page:

Syntax

<txp:yield />

The yield tag can be used as either a single tag or a container tag to return the inner content of the enclosing <txp:output_form /> tag.

The tag works in unison with the output_form tag; You place a <txp:yield /> tag in a form and then wherever you use that form the content wrapped inside the output_form tag gets placed where the yield tag was. Essentially, the value of this is that you can use forms as flexible building blocks - each building block has a common structure, but individualized content.

Attributes

Tag will accept the following attributes (case-sensitive):

default="string" v4.7.0+
The default value (see examples below). If unset, the enclosed content (if any) will be used.
Default: unset.
name="string" v4.7.0+
The name (see examples below).
Default: unset.

Examples

Example 1: Inner content and custom attributes

Given the following form named example_form:

<div>
    This content is static and will be the same every time this form is <txp:yield name="verb" default="invoked" />.
    <txp:yield />
</div>

We can invoke it twice (either in long or short form) with different inner content and attributes each time:

<txp:output_form form="example_form">
    Invoking 'example_form' with some inner content.
</txp:output_form>
<txp::example_form verb="called">
    Invoking 'example_form' again, this time with different inner content.
</txp::example_form>

And the result will be:

<div>
    This content is static and will be the same every time this form is invoked.
    Invoking 'example_form' with some inner content.
</div>
<div>
    This content is static and will be the same every time this form is called.
    Invoking 'example_form' again, this time with different inner content.
</div>

Other tags used: output_form.

Genealogy

Version 4.7.0

default and name attributes added.

Version 4.2.0

Tag support added.

If you notice any kind of problem with this page’s construction or content (outdated information, typos, broken links, or whatever), open an issue to have it sorted. Or have a go at it yourself. :)