serum v1.0.0 Serum.Template.Helpers
Provides helper macros for EEx templates.
This module provides some helper macros for use in any templates in your Serum project, mainly related to accessing website resources.
This module is automatically required and imported when each template is compiled, reducing some boilerplate codes required for creating a useful template. However, name conflicts can occur if you import other modules exporting functions/macros with the same names.
Link to this section Summary
Link to this section Functions
Link to this macro
asset(arg) (macro)
Returns the URL of the given asset.
Examples
# Suppose @site.base_url is "/mysite/".
<%= asset("images/icon.png") %>
==> /mysite/assets/images/icon.png
Link to this macro
base() (macro)
Returns the value of @site.base_url
.
Link to this macro
base(arg) (macro)
Returns the path relative to @site.base_url
.
Example
# Suppose @site.base_url is "/mysite/".
<%= base("/path/to/some_file.txt") %>
==> /mysite/path/to/some_file.txt
Link to this macro
page(arg) (macro)
Returns the URL of the given page.
Examples
# Suppose @site.base_url is "/mysite/".
<%= page("profile/my-projects") %>
==> /mysite/profile/my-projects.html
Do not append .html
extension at the end of arg
.
<%= page("profile/my-projects.html") %>
==> /mysite/profile/my-projects.html.html (bad)
Link to this macro
post(arg) (macro)
Returns the URL of the given blog post.
Examples
# Suppose @site.base_url is "/mysite/".
<%= post("2019-02-14-sample-post") %>
==> /mysite/posts/2019-02-14-sample-post.html