## Table Of Contents |
|
- [General Notes](#gn) |
- [Namespace or Skin](#ns) |
- [Class or Single Page](#cl) |
- [Template or Member Function](#tmpl) |
<!--toc--> |
|
## <span id="gn"></span>General notes |
## General notes |
|
Each block begins with its definition and ends with special command `end`. |
|
'end' [ 'namespace' | 'class' | 'template' ] |
|
This command may optionally include block type after it. For example: |
|
<% namespace vary %> |
<% class master uses data %> |
... |
<% end class %> |
<% end %> |
|
So we closed `namespace` without block type and `class` with specification. |
It may be used as additional checking of order of blocks. |
|
|
## <span id="ns"></span>namespace |
## namespace |
|
### Syntax: |
|
'namespace' (NAME|'vary') |
|
It is topmost command in every template. |
Namespace can be specified by specific name, or using `vary` keyword that mean that its name should be defined |
externally during build process using switch `-n`. |
|
### Notes |
|
- If all the skin you create would not share any part with other skin, specify its name, otherwise use `vary`. |
- You can't use both `vary` and predefined namespace withing same skin. |
|
## <span id="cl"></span>class |
## class |
|
### Syntax: |
|
'class' NAME 'uses' IDENTIFIER ['extends' NAME] |
|
Creates new class that responsible on rendering specific type of content pages. `'uses' IDENTIFIER` specifies the type of the content that this class should render. It actually defines `content` reference member of this type. |
|
Remember this note, in some cases, you would have to access `content` member directly. |
|
You can specify `'extends' NAME` if you want that new created class would inherit from other template class. |
|
### Derivation restrictions |
|
When you create derived class the content of the child should be derived from the content of its parent as well. |
For example: |
|
<% class master uses data::master %> |
.. |
<% end class %> |
<% class page uses data::page extends master %> |
... |
<% end class %> |
|
Then, `data::page` _must_ be derived from `data::master`. |
|
_Rationale:_ |
|
When you create `master` parent you need provide for it a content as well. It receives its child content, thus it |
may work if its child content derived from its parent content. |
|
### Generated Code |
|
The generated code for the above two examples would look like this (approximately): |
|
class master : public base_view { |
data::master &content; |
master(settings s,data::master cnt) : |
base_view(settings), |
content(cnt) |
{ |
... |
} |
... |
}; |
class page : public master { |
data::page &content; |
page(settings s,data::page cnt) : |
master(s,cnt), |
content(cnt) |
{ |
... |
} |
... |
}; |
|
## <span id="tmpl"></span>template |
## template |
|
### Syntax |
|
Definition of template consists of its name, round brackets and optional, comma separated list of parameters: |
|
'template' NAME '(' [ parameter [',' parameter ... ] ] ')' |
|
Where `parameters` is : |
|
IDENTIFIER ['const' ] ['&'] NAME |
|
For example: |
|
<% template render() %> |
<% template show_list(data::list_t const &list) %> |
<% template show_numbers(int x,int y, double z) %> |
|
Note: you can not specify template parameters like `list<int>`. You should define a type for them. |
|
### Generated Code |
|
Each template is translated to virtual member function of the class it defined in. This function |
returns `void` and receives defined parameters, thus, `show_list` in the above example would be |
translated to: |
|
virtual void show_list(data::list_t const &list) |
{ |
... |
} |
|
|
|