Defines a custom tag from which multiple instances can be created.
Note: class cannot be used to define transient logic tags.
<heading:class _=text *=<span size=40 bold=true {</p><text:span></p>}>>
creates a heading tag that can be used to create consistently sized heading text throughout an app, with a paragraph break before and after the heading text.
<b:class *=<span bold=true>> creates a b tag that can be used to make text bold.
None
Classes provide a way to define your own custom presentation tags (or persistent logic tags in some cases).
To be useful, a class tag must be given a name, like <tagName:class ....>. The tag name can later be used anywhere within the scope of where the tag is defined, to create a new instance of the custom tag type.
A class also requires a tag definition, defined in the * field. This definition must consist of a single presentation or persistent logic tag, which may optionally be given a name of its own. That tag may itself contain as many tags and fields as needed to define the custom tag's appearance and behaviour.
All tag and field names within the definition are internal to the tag definition. They are hidden from the user of that tag. To expose tags and fields to the user, add fields to the class tag, where each field contains the path to the corresponding field inside the tag definition. Set the _ field to define which internal tag or field the custom tag's primary field will correspond to.
If you do not set the _ field, the custom tag's primary field will correspond to the primary field of the main tag inside the tag definition.
The following example creates a heading class, with the heading's text size exposed as a field so that headings of different levels can be created.
<heading:class _=text size=text.size *=
<span bold=true {</p><text:span size=30 {}></p>}>
>
<heading size=40 {Top level heading}>
<heading size=26 {Sub-heading}>
<heading {Default size}>
Body text
Top level headingThe class defines a span containing an inner span named text. The _ field
makes the class's primary field correspond to text, so each heading's text goes there, between two paragraph
breaks. The size field is exposed as the size field of text, so it can be given
when each heading is created; the definition gives it a default of 30.
Field values given to an instance are applied after the definition has been carried out. In ioL version 1.05, this means a value calculated inside the definition (for example a size worked out from another exposed field) uses the definition's default rather than the instance's value. Expose the field to be changed directly, as above.
Fields that aren't exposed are hidden from outside the instance, including from code that reaches the instance through a reference pointer.