spiralcraft.textgen Syntax Reference

Built-in Elements

These elements provide common run-time functionality, and can be included in any markup system extended from spiralcraft.textgen without using a namespace prefix.

Eval

Output the result on the expression

<%=x+y*z/%>

If

Activate a group of elements when the condition is true

<%If x='condition'%>
  ...
<%/If%>

Else

Activate an alternate group of elements when the condition is false

<%If x='condition'%>
  ...
  <%Else/%>
  ...
<%/If%>

With

Make the value returned by the expression the subject of the local Focus for child elements.

<%With x='somePerson'%>
  <%=.firstName/%> <%=.lastName/%>
<%/With%>

Iterate

Iterate through a collection or array

<%Iterate x='somePersonCollection'%>
  <%=[Iterate] index/%>: <%=.name/%>, <%=.value/%><br/>
<%/Iterate%>

Group

Output a header and/or footer when the value of an expression changes

DateFormat

Format a date

<%DateFormat x="someDate" format="yyyy-MM-dd" timeZone="someTimeZone"/%>

SharedReference

Create a single object shared by all threads and visible to child elements

<%SharedReference typeX="[@mytypes:MyWidget]" instanceURI="myWidgetConfig"/%>
  ...
    <%=[mytypes:MyWidget] myProperty/%>
  ...
<%/SharedReference%>

LocalReference

Create an object scoped to the state tree (ie. the session model) and visible to child elements

<%LocalReference typeX="[@mytypes:MyWidget]" instanceURI="myWidgetConfig"/%>
  ...
    <%=[mytypes:MyWidget] myProperty/%>
  ...
<%/LocalReference%>

Meta Elements / Processing Elements

These elements manipulate markup resources and the page compilation process itself

@include

Include a resource, possibly using it as a wrapper

 <%@include resource="../myfile.textgen"/%>
 <%@include resource="../wrapper.textgen"%>
   This goes inside the wrapper where the wrapper puts @insert
 <%/@include%>

@insert

Insert a predefined content block

 This is a wrapper around the content
   <%@insert/%>
 inside the @include that included me
 Here is some predefined content <%@insert name="myPredefinedBlock"/%>

@define

Define a content block to be activated and/or bound in a different context

 <%@include resource="myTemplate"%>
   <%@define name="mySpecificContent"%>
     This is customized and will go into the template and be rendered as a closure
     <%=myCustomExpression/%>
     <%mytags:MyTag/%>
   <%@/define%>
 <%/@include%>

@namespace

Define a namespace prefix for use in tag names and spiralcraft.lang Expressions

 <%@namespace mytypes="class:/mypackage/mytypes/"%>
   <%mytypes:MyElement x="[mytypes:MyType] someProperty"/>
 <%/@namespace%>

@comment

Suppress activation of a content block

 <%@comment%>Don't activate this<%/@comment%>