Common mistakes and tricks

Since Twital internally uses XML, you need to pay attention to some aspects while writing a template. All templates must be XML valid (some exceptions are allowed…).

  • All templates must have one root node. When needed, you can use the t:omit node to enclose other nodes.

  • A template must be well formatted (opening and closing nodes, entities, DTD, etc…). Some aspects as namespaces, HTML5 & HTML entities, non-self closing tags can be “repaired”, but it is recommended to be closer to XML as much as possible.

    The example below lacks the br self closing slash, but using the HTML5 source adapter it can be omitted.

  • The usage of & must follow XML syntax rules.

        &amp; <!-- to output "&" you have to write "&amp;" -->
        &lt; <!-- to output "<" you have to write "&lt;" -->
        &gt; <!-- to output ">" you have to write "&gt;" -->
        <!-- you can use all numeric entities -->
        &#160; &#160;
        <!-- you should not use named entities (&euro;)-->
  • To be compatible with all browsers, the use of the script tag should be combined with CDATA sections and script comments.

    if ( 1 > 2 && 2 < 0){
        alert(' ok ')
    head {
        color: red;