This is reference material for developing osys email templates for Osmosys.
Osmosys's templating language osys uses HTML attributes to describe how the DOM should be parsed into both an interactive UI and an automated, dynamic template that can be generated on a server.
Note that throughout the documentation you will not see attributes enclosed in brackets ([]
) in code snippets. Outside of code snippets, you will see them enclosed in brackets in a similar style to CSS selectors. You should not be using brackets around Osmosys attributes in your templates.
So you may see the [osys][osys:field="My great field"]
attribute used in a sentance with brackets, but do not include the brackets when writing your HTML:
This is wrong:
<div [osys][osys:field="My great field"]></div>
This is right:
<div osys osys:field="My great field"></div>
Osmosys attributes can be on both block elements and inline elements. Osmosys does not change the presentation of the UI depending on the visual appearence or CSS styling of your tag.
The Osmsoys editor is concerned principally with function over form. This may change as the UX gets updated, but right now, you need not worry how your [osys]
tags will look in the UI.
This attribute will register or initialize your element with Osmosys.
All osys elements are tagged like so, with a simple [osys]
attribute:
<a osys href=""></a>
<div osys></div>
Either a tag is an [osys:field]
, [osys:group]
.
Field tags stand on their own and don't rely on other tags to function. Most of the time, these will be simple text
or html
fields, but more complex fields may have multiple inputs on them.
You can specify a label by passing a string to it:
[osys][osys:field="My great field"]
You can specify multiple fields on a single element:
<a
osys
osys:name="Headline Link"
// Field 1
osys:field:1="My URL"
osys:field:1:target="href"
osys:field:1:type="url"
// Field 2
osys:field:2="My Text"
osys:field:2:target="title,alt,children"
osys:field:2:type="text"
></a>
Types tell Osmosys which form element to populate the UI with and ultimately what kind of content can go where.
value | name | description |
---|---|---|
html |
HTML | Could be a 100 character intro or 12,000 word essay with photos, videos, and social media all mixed together. This is where Osmosys shines. |
text |
Text | Simple, unassuming plain jane text. You can tell it to parse HTML characters, or just leave them be. |
datetime |
Date | Power your template's dates with moment.js formatting, current times, and even timezones (coming soon). |
url |
URL | Can simply be a link to an article, or an image upload waiting to happen |
ad |
Ad | Dynamically pull in ad code that you have saved in Osmosys. |
Providing multiple types separated with commas means that the user can switch between them as their content demands:
[osys][osys:field][osys:field:type="html,text"]
Targets tell where to place in the template the value put in the form.
Targets can either be an attribute like href
or title
. Or they can represent a population of the inside of the tag with children
. (See the [osys:unwrap]
modifier if you are interested in similar functionality to JavaScript's outerHTML
total node replacement).
You can specify multiple targets that will receive the same value.
<h1
osys
osys:name="Big Headline"
osys:field
osys:field:target="children"
osys:field:type="text,html"
></h1>
To supply different values to different targets, use multiple fields:
<a
osys
osys:name="Card link"
// Field 1
osys:field:1="Card content"
osys:field:1:target="children"
osys:field:1:type="html,text"
// Field 2
osys:field:2="Description text"
osys:field:2:target="title,alt"
osys:field:2:type="text"
// Field 3
osys:field:3="Link URL"
osys:field:3:target="href"
osys:field:3:type="url"
></a>
Fields can be nested within each other, but they will appear as separate elements in the UI. Parent fields cannot populate the target children
.
<a
osys
osys:name="Card link"
// Field 1
osys:field:1="Card content"
osys:field:1:target="children"
osys:field:1:type="html,text"
// Field 2
osys:field:2="Description text"
osys:field:2:target="title,alt"
osys:field:2:type="text"
// Field 3
osys:field:3="Link URL"
osys:field:3:target="href"
osys:field:3:type="url"
>
<img
/>
</a>
A group contains a set of fields that can be populated all with one content population.
Example:
<div osys osys:name="Content group" osys:group>
<a osys osys:field="Link" osys:field:target="href" osys:field:type="url">
<img
osys
osys:name="Card link"
osys:field:1="Image"
osys:field:1:target="src"
osys:field:1:type="url"
osys:field:2="Description text"
osys:field:2:target="title,alt"
osys:field:2:type="text"
/>
<p
osys
osys:name="Caption"
osys:field="Link URL"
osys:field:target="href"
osys:field:type="url"
></p>
</a>
</div>
Example:
<div
osys
osys:name="Main content well"
osys:repeating
osys:repeating:min="2"
osys:repeating:default="3"
osys:repeating:max="5"
>
<div osys osys:repeat osys:name="Ad" osys:field osys:field:type="ad"></div>
<div osys osys:repeat osys:name="Content group" osys:group>
<a osys osys:field="Link" osys:field:target="href" osys:field:type="url">
<img
osys
osys:name="Card link"
osys:field:1="Image"
osys:field:1:target="src"
osys:field:1:type="url"
osys:field:2="Description text"
osys:field:2:target="title,alt"
osys:field:2:type="text"
/>
<p
osys
osys:name="Caption"
osys:field="Link URL"
osys:field:target="href"
osys:field:type="url"
></p>
</a>
</div>
</div>
A modifiy can be used on either a field or a group
If you wish to remove the tag as you place content in it, use [osys:unwrap]
(this is sort of like outerHTML
).
Before content population:
<td>
<div
osys
osys:name="Big Headline"
osys:field
osys:field:target="children"
osys:field:type="text,html"
osys:unwrap
></div>
</td>
After content population:
<td>Lorem ipsum dolor</td>
<td>
<div
osys
osys:name="Big Hidden Headline"
osys:field
osys:field:target="children"
osys:field:type="text,html"
osys:hideable
>
This is shown
</div>
</td>
<td>
<div
osys
osys:name="Big Hidden Headline"
osys:field
osys:field:target="children"
osys:field:type="text,html"
osys:hideable="true"
>
This is hidden
</div>
</td>