====== WACT Template Syntax ====== The WACT template syntax uses XML markup to "extend" HTML (or whatever XML vocabulary you are using) with tags and attributes to allow declarative logic to be used in the template. Compared to more common styles of template engines implemented in PHP (see [[pattern:Template View]]), it can be a little confusing to begin with. However, once grasped, it provides a powerful mechanism for rendering content as well as clean separation between application and presentation logic. **Note**: as far as is possible, the syntax has been designed to allow WACT templates to be edited in a WYSIWYG editor, such as [[http://www.macromedia.com/software/dreamweaver/|Macromedia's DreamWeaver]]. There are a number of key points which need to be understood when working with the WACT's templates: ===== CompileTime vs. RunTime ===== WACT handles templates in two stages; a compiling stage ([[Compile Time]]) and an execution stage ([[Run Time]]) (see also [[Template Component Architecture]]). During the compiling stage, your template is parsed and a [[Compile Time]] [[Component Tree]] is constructed to represent it. In [[Compile Time]] [[Component Tree]] are objects (subclasses from [[class:Compiler Component]]) which write output into the //compiled// template. The compiled template is your WACT template compiled into a native PHP script, ready for execution. During the execution stage, the compiled template is invoked and a lightweight (fast) runtime component tree is built (each component in the tree being a subclass of [[class:Component]]), which you have access to via the [[class:Template]] API, allowing you to control the runtime components. Because the compiling stage is expensive, in terms of performance, you can disable it with the ''config.ini'' setting ''FORCECOMPILE = FALSE''. Normally you will only use the compile stage when you are developing an application and the template is being modified. Once the application is "live", the compiling stage should be disabled (the template is not changing), meaning only the fast, [[Run Time]] stage takes place. ===== Tag Types ===== There are four flavours of tag in WACT (see also [[Supported Tags]] and [[Tag Developers Guide]]); ==== Silent Compiler Directive Tags ==== Silent compiler directive tags provide instructions to the template engine, influencing template compile-time behaviour but without writing anything to the compiled template. They also do not have a runtime component. That means when you load the template from your PHP script, via the [[class:Template]] class, there is no opportunity to interact with them - they do not exist at runtime and have no entry in the runtime component tree (you cannot find them with the [[class:Template]]::getChild() method). They are the least common type of tag in WACT although examples include the [[tag:core:set|Core Set Tag]] (used to set the value of a variable reference so the value gets written into the compiled template); and the [[tag:core:import|Core Import Tag]] (used to import a set of values to be written into the compiled template): ==== Compiler Directive Tags ==== Like silent compiler directive tags, compiler directive tags do not have runtime components, but they **do** write into the compiled template. Examples include the [[tag:core:include|Core Include Tag]] (used to include one template in another, much like the PHP [[phpfn>include]] function): [[tag:core:optional|Core Optional Tag]] and [[tag:core:default|Core Default]] tags (used for an if/else type condition in the template, depending whether the variable names in the for attribute has been set in the [[class:DataSpace]]); You are logged in You are not logged in ==== Server Component Tags ==== Server component tags **do** have a corresponding runtime component which you can interact with from your PHP script, via the [[class:Template]] API **and** they write into the compiled template. They are the most common type of tag in WACT, examples include the [[tag:core:block|Core Block Tag]] (marks a section of the template which can be hidden or displayed dynamically at runtime): and the [[tag:calendar:month|Calendar Month Tag]] (used to build a navigable calendar for a month) Server tag component tags are a powerful feature in WACTs template engine, for example: * '''' [[tag:page:navigator|tag]] generates navigation for paged result sets and can easily be attached to a '''' [[tag:list:list|tag]]. * '''' [[tag:calendar:month|tag]] builds a navigable HTML table to represent a calendar month, without you needing to worry about the HTML or the math working behind the scenes that calculates the calendar. ==== Server Data Component Tags ==== The [[Server Data Component Tag]] is an extension of the [[Server Component Tag]] and deals with connecting a [[class:DataSource]] to a tag. Otherwise the same rules apply as with the [[Server Component Tag]] - there is corresponding runtime component and it writes into the compiled template. Some examples of [[Server Data Component Tag]]s are: * '''' [[tag:list:list|tag]] makes it very easy to loop through a [[class:Record Set]] and embed it in HTML. * '''' [[tag:data:table|tag]] allows you to generate instant HTML tables for a [[class:Record Set]] (without typing a single '''' tag) ==== Server Tag Component Tags ==== Server tag component tags are an extension of server component tags (they have a runtime component and they write into the compiled template) but the important difference is they **also** correspond to native tag names in the XML vocabulary you are using. For example the [[tag:form:select|Select Tag]] corresponds to the HTML ''

In other words all those ''