Runbox.Notifications.TemplateHelper (runbox v7.0.1)
Set of utility functions for use in notification templates.
Link to this section Summary
Functions
Returns a URL to the asset detail.
Formats a number by separating thousands with a separator.
Formats timestamp into the given format in the given timezone.
Wraps the given EEx content with a EEx template.
Returns the UI url.
Link to this section Functions
asset_link(asset_id, ui_type \\ :new)
Returns a URL to the asset detail.
The type of UI can be specified, and the link is generated to work with that UI. Can be :new
or
:old
.
format_number(number, separator \\ " ")
Formats a number by separating thousands with a separator.
format_ts(ts, format_str, target_tz \\ "Etc/UTC")
Formats timestamp into the given format in the given timezone.
Wraps the given EEx content with a EEx template.
Templates can be bundled with a scenario or be a part of the system, source
should be set to scenario_name
for scenario-based
templates and :system
for templates bundled with the system.
The templates that can be included, so called shared templates, are stored in
shared
folder
(scenarios/priv/notifications/{scenario_name}/shared
).
Each shared template consists of two files - header and footer - which are
wrapped around the given content. The filenames have _header
and _footer
appended, for template_name = "email"
the two filenames are
email_header.eex
and email_footer.eex
. System templates are stored in
apps/asset_map/templates/shared
.
Via context
you can pass additional parameters to the shared template
(passed as assigns). The expected context depends on the template.
example-usage
Example usage
<% alias Runbox.Notifications.TemplateHelper %>
<% require TemplateHelper %>
<%= TemplateHelper.include_template({"test", 1}, "email_rich", title: "Test email") do %>
<h1>Test Email</h1>
<p>This text is surrounded by the template...</p>
<% end %>
ui_url()
Returns the UI url.