Most Emissary Templates will need to display HTML contents. This is done using the view-html
step, which wraps the current object in a corresponding “builder” class, then passes this builder to the named Go HTML/Template. Here is an example from a template.json
file:
{
"actions": {
"view": {
"steps": [
{"do":"view-html"}
]
}
}
}
In this template, the corresponding view.html
is a standard Go HTML/Template that might look like the example below. Notice the replacement tokens in {{}}
. These values are provided by the Builder
class generated for this page, which contains all of the data accessors required to build a complete application in Emissary. Builders are documented in the section below.
<div class="page" hx-get="/{{.StreamID}}" hx-trigger="refreshPage from:window" hx-target="this" hx-swap="outerHTML" hx-push-url="false">
<div id="menu-bar">
<div class="left">
<a hx-get="/{{.StreamID}}/edit">Edit List</a>
</div>
<div class="right">
<a hx-get="/{{.StreamID}}/delete" class="text-red">Delete</a>
</div>
</div>
<article>
<h1>{{.Title}}</h1>
<div>{{.Summary}}</div>
<div>{{.ContentHTML}}</div>
</article>
</div>
Common Builders
Most custom Templates will work with Streams
, the data type that contains most content in an Emissary application. Streams are backed by the Stream Builder class.
In addition to Streams, there are several other kinds of builders which are used in specialized parts of an Emissary site.
All builders inherit methods from the Common Builder, which provides data accessors for site-wide data, and commonly used queries.
Builder | Description |
---|---|
Folder | Created by with-folder step. Provides data accessors for Folder types using the generic Model builder. |
Follower | Created by with-follower step. Provides data accessors for “Follower” types using the generic Model builder. |
Following | Created by with-following step. Provides data accessors for “Following” types using the generic Model builder. |
Inbox | Only available to routes beginning with /@me/inbox . Provides data accessors for the current user’s inbox. |
Message | Created by with-message step. Provides data accessors for “Message” types using the generic Model builder. |
Outbox | Only available to routes beginning with /@userId/... . Provides data accessors for the named user’s profile and outbox. |
Response | Created by with-response step. Provides data accessors for “Response” types using the generic Model builder. |
Stream | Created for all other routes. Provides data accessors for the currently visible Stream |
Admin Builders
The domain administrator can modify to core system features through routes beginning with /admin
. These hard-coded routes use their own builders, which are locked to admin use only.
Builder | Description |
---|---|
Admin Domain | Domain-specific accessors for /admin/domains route |
Admin Group | Group-specific accessors for /admin/groups route |
Admin Navigation | Top-level navigation accessors for /admin/navigation route |
Admin Rule | Rule-specific accessors for /admin/rules route |
Admin User | User-specific accessors for /admin/users route |