Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (58 sloc) 2.98 KB
== [[SYNTAX]] SYNTAX
This section explains <<eRuby>> template syntax and Ember extensions thereof.
eRuby templates are plain-text documents that contain special processing
instructions known as *directives*. These instructions are evaluated _in
place_, meaning that they are replaced by the result of their evaluation.
=== Directives
Directives are expressed in either *standard* or *shorthand* notation:
[options="header"]
|=============================================================================
| Notation | Directive | Head | Operation | Body | Tail
| Standard | <%%xy%> | <%% | x | y | %>
| Shorthand | %xy | % | x | y |
|=============================================================================
In standard notation, the directive is composed of a *head*, an
*operation*, a *body*, and a *tail*; and it may appear anywhere in the
template.
In shorthand notation, the directive is composed of a *head*, an
*operation*, and a *body*; and it may only appear in the template if it
occupies an entire line (leading whitespace is permitted only in Ember;
trailing whitespace is permitted in both Ember and eRuby).
Regardless of the notation used, directives are atomic constructs; they cannot
be nested within one another.
=== Operations
An *operation* is the first character following the head of a directive. It
specifies how the directive will be processed.
Ember supports the following operations, and here is what they do:
[horizontal]
%%::
One "%" character is omitted from the head of the directive and the entire
directive is inserted into the output.
#::
The entire directive is omitted from the output.
=::
The body of the directive is evaluated as Ruby code, and the result of
this evaluation is inserted into the output.
~::
(only in Ember) The body of the directive is evaluated as an eRuby
template, and the result of this evaluation is inserted into the output.
+::
(only in Ember) The body of the directive is evaluated as Ruby code, and
the result of this evaluation is assumed to be a string that specifies the
path (either absolute or relative to the eRuby template file in which this
directive is found) to a file containing an eRuby template. This file is
read and its contents are evaluated as an eRuby template, and the result
of this evaluation is inserted into the output.
<::
(only in Ember) The body of the directive is evaluated as Ruby code, and
the result of this evaluation is assumed to be a string that specifies the
path (either absolute or relative to the eRuby template file in which this
directive is found) to a file. This file is read and its contents are
inserted into the output.
|::
(only in Ember) The body of the directive is treated as the beginning of a
Ruby block. The *do* keyword is automatically appended to the body of the
directive if missing.
None of the above::
The body of the directive is evaluated as Ruby code, but the result of this
evaluation _is not_ inserted into the output.