Wafl Home

HTML Tutorial

HTML Templates

HTML templates technique provides a string syntax that is customized to Web development. If a string contains elements of an HTML document, it easier to write it without additional quotes and escape symbols, using a usual HTML syntax.

An HTML template begins with html template and ends with <#>:

html template
    <div class="myClass">
        This is a template
    </div>
<#>

All blanks are preserved in HTML templates, except at the beginning and the end of the template. The only restriction is that the template body must not contain the character pair <#, which is not valid in HTML anyway.

HTML templates may contain special Wafl expression tags, <#...#>, with any Wafl expressions of string type:

html template
    <div class="myClass"><# l.strJoin("<br/>") #></div>
<#>

An HTML template is semantically equivalent to a sequence of string concatenations. For example, a former example is equivalent to:

"<div class=\"myClass\">" + l.strJoin("<br/>") + "</div>"

Source code:

q( 'John Doe' )
where {
    q( name ) = html template
        <html>
        <body>
            Hello <# name #>,<br/>
            How do you like Wafl?
        </body>
        </html>
        <#>;
}

Result:

"<html>
        <body>
            Hello John Doe,<br/>
            How do you like Wafl?
        </body>
        </html>
        "

 

Table of Contents

Let's Start

Program Structure

Primitive Data Types

List

Tuple

Record

HTML

Command Line Interpreter

Using Web Servers

Syntax

Examples

Tips

The most of examples evaluates with both command line and Web server Wafl interpreters. If any example is based on specific features of an interpreter, it is explicitly annotated.