===== Output Expressions ===== There are two ways to embed output expressions into a template: The tag ''[[tag:core:output| tag]]'' allows an expression to be specified in the value attribute: There is a short cut syntax using {}: ''{$Expression}'' The two are equivalent, but the shortcut is more common. The shortcut may be used in places where the tag version cannot, such as in attributes. '''' By default, WACT makes the result of output expressions into "safe" HTML output. Special characters such as ' (single-quote), " (double-quote), & (ampersand), < (less-than sign), and > (greater-than sign) are converted into their equivelent HTML entities. ==== Data Binding Expressions ==== The simplest expression is a data binding expression. It uses an named property to access data provided to the template by the application. Here is an example of a typical data binding expression used in an output expression: ''{$UserName}'' This creates a placeholder in the template that will be replaced by the real value of the user's name when the application runs. Data Binding expressions typically appear in output expressions, but they do not have to. The ''[[tag:core:default|]]'' and ''[[tag:core:optional|]]'' tags are examples of tags which use a data binding expression. Anonymous In this example "UserName" is the databinding expression. ==== Template properties ==== You can use the [[tag:core:set| Tag]] to define properties in the template. These properties take precedence over any properties that the application might provide. ==== Predefined properties ==== Tags in WACT may also define properties. A good example is the ''{$ListRowOdd}'' property defined by the ''[[tag:list:list| Tag]]''. This property can be used to show rows with alternating colors: ==== Filtering output expressions ==== You may specify a specific output format for your output expressions using WACT filters. THe syntax is: ''{$UserName|trim|capitalize}'' In this example, the trim filter removes leading and trailing whitespace, and then the capitalize filter is applied second. Filters may also require additional information called parameters. The syntax for specifying parameters is ''{$UserName|default:"anonymous"}'' This is equivalent to the earlier example of the ''[[tag:core:default| Tag]]''. If no value is specified by the application for the ''UserName'' property, then the value of anonymous is used. A parameter may be either a number constant, a string constant, or a databinding expression. Here is an example using a databinding expression:
{$PlainText|wordwrap:size}
Multiple parameters may be specified separated by commas. Some available filters are: [[filter:core:capitalize|Capitalize Filter]], [[filter:core:lowercase|Lower Case Filter]], [[filter:core:notags|No Tags Filter]], [[filter:core:text|Text Filter]], [[filter:core:trim|Trim Filter]], [[filter:core:uppercase|Upper Case Filter]], [[filter:core:wordwrap|Word-Wrap Filter]], [[filter:core:date|Date Filter]], [[filter:core:number|Number Filter]], [[filter:core:math|Math Filter]]. If you wish to circumvent WACT's default entity conversion, you can specify the special filter raw. The raw filter must always appear at the end of a chain of filters. ''{$CommentHtml|raw}'' This is required if the application you are creating templates for passes HTML data to the template. ==== Constants ==== You may specify constants in your output expressions in place of the normal data binding expression. ''{"this is a constant"}'' ''{23}'' This can be useful with special filters: search ==== Data Sources ==== Properties are provided to the template inside of datasources. Normally, the template provides a default datasource. The template may also specify alternate datasources using the ''[[tag:core:datasource| Tag]]''. These datasources form a hierarchy. Databinding expressions may be used to navigate this hierarchy. A databinding expression prefixed with a ''#'' will access the top level, or default datasource. The ''^'' prefix may be used to access the datasource one level higher than the current datasource. This prefix may be used multiple times. Some examples: ''{$#TodaysDate}'' ''{$^UserName}'' ''{$^^UserName}'' This syntax may be used anywhere a databinding expression may appear: Anonymous ---- ===== Related Documents ===== [[wact:template_syntax|Template Syntax]] This page needs work. Please help out. Keep this page in the perspective of an html designer/template author. No PHP code here!