Mirror of the Rel4tion website/wiki source, view at <http://rel4tion.org>
Clone
HTTPS:
git clone https://vervis.peers.community/repos/yEzqv
SSH:
git clone USERNAME@vervis.peers.community:yEzqv
Branches
Tags
07-meta-statements.mdwn
[[!meta title=“3.7 | Meta Statements”]]
Meta Statements
Idan supports generation of statements using templates. The template definitions are external to Idan, and allow extending it and providing convenient access to common patterns.
Defining Templates
Templates may be defined using Smaoin itself. There is a vocabulary for Idan, placed under the idan
namespace. The definitions are provided as part of [[/projects/Kadma]].
[[!template id=todo text=“Explain the idan vocabulary and write .idan file”]]
Using Templates
Once defined, templates can be used in Idan through meta statements. A meta statement is a syntactic form which contains the parameters required for instantiating the template, i.e. creating regular statements from it. A meta statement is therefore a combination of a template and a list of parameters.
The template is specified as a statement component with slight variation. It can be a Uid of the template, or a reference. But it cannot be a generator. Regardless of which form is used, the template must be prefixed with a plus sign (+
). That is what marks the whole statement as a meta statement.
There are two forms for writing meta statements. The first form is the application form. It begins with the template literal, followed by a whitespace separated list of parameters. Example:
+myns:some_template 1 "two" 3.0^1 ||NAo=|| myns:thing &something
This is a meta statement which generates statements from a template specified as the first component, and 6 parameters specified sequentially after it.
The second form is the statement form. Instead of writing the template first and then the parameters, the first parameter is written before the template. The result looks more like a statement, especially if the template reference has a name in similar style to property names. This form is possible only if the first parameter is a resource. Values as first parameters are invalid. Example:
myns:thing +myns:some_template 1 "two" 3.0^1 ||NAo=|| &something
To get the equivalent application form, switch places between the first two components.
In statement form, meta statements can be used inside statement blocks, sharing the block’s subject as the first parameter. Example:
<%>
myns:name "John Doe"
+myns:some_template &something