View Source Runbox.Notifications.TemplateHelper (runbox v13.0.3)
Set of utility functions for use in notification templates.
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.
Functions
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
.
Formats a number by separating thousands with a separator.
Formats timestamp into the given format in the given timezone.
include_template(source, template_name, context \\ [], macro_params)
View Source (macro)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
<% 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 %>
Returns the UI url.