Vision Reference

Directives

Following is an alphabetical list of all directives in Vision, along with a brief description and a link to the corresponding section of the tutorial.

@chdir
Change the current working directory.
@day
Get the current day.
@define
Define a template.
@eval
Evaluate a string as Vision code.
@expand
Explicit expansion.
@export
Export an identifier to the enclosing scope.
@hour
Get the current hour.
@ifdef
Expand if an identifier is defined.
@ifndef
Expand if an identifier is not defined.
@include
Include a Vision file.
@local
Create a new local scope.
@minute
Get the current minute.
@month
Get the current month.
@quote
Escape shell characters.
@second
Get the current second.
@system
Execute a system command.
@unix
Execute a Unix command.
@windows
Execute a Windows command.
@year
Get the current year.

Standard Library

Vision has a growing standard library of templates to use for many common tasks. Their contents can be imported using the @include directive. These templates can be installed anywhere, but conventionally should be in a subdirectory named vision in the same directory as other page templates.

The standard library is arranged hierarchically based on dependencies, with many convenience headers.

entities

The entities family of headers defines HTML character entities as template variables, to improve legibility by allowing, for example, ' ' to be replaced with simply nbsp. The entities are divided into logical sections according to use:

entities/all
All other entities headers.
entities/accents
Accents and accented characters.
entities/arrows
Arrows. That's not a trick.
entities/greek
Greek characters.
entities/math
Mathematical symbols, plus arrows and greek.
entities/punct
Punctuation and symbols.
entities/sgml
SGML markup-significant characters.
entities/spacing
Spaces and modifiers, such as nbsp, zwj, and rlm.

functional

This is an experimental header and is subject to change.

The functional header defines templates for basic Boolean logic, which will be extended in the future by judicious additions of both built-in features and Vision-based combinations of those features.

The true and false templates are used to represent the corresponding truth values in Boolean logic. These templates must be used for truth values to ensure correct interpretation of the Boolean functions. There is no automatic conversion to Booleans.

The and, or, xor, and not templates produce the truth value corresponding to the result of the given Boolean operation on the one or two supplied arguments. For instance, and { true, true } returns true.

The if template expands the remainder of its content if its first parameter is true, e.g., if { true; 'Hello' } expands to Hello.

The defined template can be used to obtain a truth value for whether a variable is defined, e.g., defined:'var' evaluates to true if var is defined or false otherwise.

html

The html header defines a few miscellaneous templates that might commonly be used in HTML and XHTML documents. All identifiers are prefixed with html:.

stylesheet
Shorthand for linking to an external CSS stylesheet.
javascript
Shorthand for linking to an external Javascript file.

These templates are not for inline stylesheets or scripts. Use of such inline content in Vision is considered bad form.

@include 'vision/html';

html {
    head {
        title : 'Test';
        html:stylesheet : '/style.css';
        html:javascript : 'http://code.jquery.com/jquery-1.4.2.js';
    }
    body : '...';
}

util

util contains just a few utility templates.

null
An empty string, used to erase a variable or create an empty tag with both opening and closing parts.
group
Evaluates and returns its contents as a single value. Used to supply multiple elements to a template that accepts a limited number of arguments.
newline
A literal newline, in case you ever happen to need one.

xhtml

The xhtml header defines handy templates for generating XHTML documents. It also includes the util and html headers. All identifiers are prefixed with xhtml: for consistency.

strict
Creates a proper XHTML 1.0 Strict document.
transitional
Creates a proper XHTML 1.0 Transitional document.
strict:doctype
The DOCTYPE declaration for an XHTML 1.0 Strict document.
transitional:doctype
The DOCTYPE declaration for an XHTML 1.0 Transitional document.
@include 'vision/xhtml';

xhtml:strict {
    head {
        title : "ExampleCo";
    }
    body {
        "ExampleContent."
    }
}