I'm writing a small website in rust rocket. I'm using handlebar templates, and the way you return a Template
form a handler is quite convenient. But I also want to use my template engine for emails I'm sending out. The problem is, that Templates in rocket_contrib
do not really support rendering to a String
.
There is a method show()
, that creates Option<String>
, but that one is not supposed to be used.
Render the template named name located at the path root with the context context into a String. This method is very slow and should not be used in any running Rocket application. This method should only be used during testing to validate Template responses. For other uses, use
render
instead.
The method render()
is what you normally use, but this one returns a Template
, which is what I started with... You return those and rocket does its magic to produce the resulting html-page.
Is there any way to use my templates in rocket for emails? My mailer (lettre) expects a String.