Views
Igo.js renders HTML through @igojs/dust — full template syntax is documented there. This page focuses on how views integrate with the server: the view engine, view helpers, and the built-in @dateformat helper.
Layout
Templates live in /views:
views/
├── layouts/
│ └── default.dust
├── users/
│ ├── index.dust
│ └── show.dust
└── emails/
└── welcome.mjmlRender from a controller:
module.exports.show = async (req, res) => {
res.render('users/show', { user }); // → /views/users/show.dust
};The view engine is wired up automatically by @igojs/server (Dust as the engine, /views as the directory, view cache enabled in production).
Built-in helpers
In addition to the helpers shipped with @igojs/dust, Igo.js registers two helpers in the server layer.
@t — translations
Available in every template through res.locals.t (set by the i18n middleware):
<h1>{@t key="welcome.title" /}</h1>
<p>{@t key="welcome.hello" name=user.name /}</p>Backed by i18next. Translation files live in /locales/<lang>/translation.json — see i18n.
@dateformat — date formatting
Formats Date values via moment.js. Strings are passed through unchanged.
{@dateformat date=user.created_at /}
{@dateformat date=user.created_at format="DD/MM/YYYY" /}
{@dateformat date=user.created_at format="calendar" /}
{@dateformat date=user.created_at format="LLLL" lang="fr" /}formatdefaults to'YYYY-MM-DD HH:mm:ss'.'calendar'uses moment's relative.calendar()output.langdefaults to the current request language (res.locals.lang). Passlang=to override per-call.
Custom view helpers
Register additional Dust helpers and filters in /app/helpers.js:
// app/helpers.js
module.exports.init = (dust) => {
// @nl2br helper — convert newlines to <br/>
dust.helpers.nl2br = (params) => {
if (!params.value) return '';
return params.value.replace(/\r?\n/g, '<br/>');
};
// money filter — format numbers as currency
dust.filters.money = (value) => '$' + Number(value).toFixed(2);
};{@nl2br value=description /}
{price|money}The file is loaded automatically at startup if it exists. The dust argument is the @igojs/dust module — see Custom Helpers and Custom Filters for the API.