It is rendered by bounding the context of a mailer and using a template engine.
For convenience, there is a correlation between the view mailer name and the template file name. It’s the translation of the name into a path: from Mailers::ForgotPassword
to forgot_password
.
The remaining part is made of multiple file extensions. The first is relative to the format and the latter is for the template engine.
For a given mailer named Mailers::ForgotPassword
, there must be at least one template forgot_password.[format].[engine]
under the mailers templates directory.
If we want to associate a different template to a mailer, we can use template
.
Our view will look for lib/bookshelf/mailers/templates/send_password.*
template.
This is a list of the supported engines. They are listed in order of higher precedence, for a given extension. For instance, if ERubis is loaded, it will be preferred over ERb to render .erb
templates.
In order to use a different template engine we need to bundle the gem and to use the right file extension.
Templates are located in the default directory mailers/templates
, located under an application’s directory lib/bookshelf
, where bookshelf
is the name of our application. If we want to customize this location, we can set a different value in Hanami::Mailer configuration.