Rocket: [Feature Idea] Register templates from strings, rust-embed, or equivalent

Created on 17 Mar 2017  路  5Comments  路  Source: SergioBenitez/Rocket

This feature would be required to allow strings embedded in the program (specifically like in https://github.com/SergioBenitez/Rocket/issues/227) to be used as templates.
Currently rocket_contrib::Template only supports templates which exist on the real file system.

This feature could exist outside of rocket, by just using the template engine directly and passing in the template string and context. However, this feature may still make sense in rocket_contrib to remove boilerplate from the common desire to embed static files in the executable.

This feature may also be solved by or related to implementing https://github.com/SergioBenitez/Rocket/issues/64.

Issue was labelled as idea instead of request, mostly because I'm looking for input and less certain about what shape the ideal solution will be in.

enhancement

Most helpful comment

This would be very nice.

Distributing the templates when deploying the binary is quite annoying.

Diesel has an embed_migrations!("the/path") macro to load migrations from the file system at compile time and embed them into the code.

That would be pretty awesome.

All 5 comments

What about using https://maud.lambda.xyz?

I think this is a good idea. Right now, e.g. Maud can already work with Rocket (see the maud documentation), as when Maud's rocket feature is enabled, an impl of the Responder trait is generated for maud HTML. Of course, that means skipping the template layer, and calling Maud's functionality in-line.

Being able to wrap with the Template type would allow for a cleaner separation of concerns.

This would be very nice.

Distributing the templates when deploying the binary is quite annoying.

Diesel has an embed_migrations!("the/path") macro to load migrations from the file system at compile time and embed them into the code.

That would be pretty awesome.

500 might make this possible.

https://github.com/SergioBenitez/Rocket/pull/521 will land shortly and make this possible!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lambda-fairy picture lambda-fairy  路  4Comments

klnusbaum picture klnusbaum  路  4Comments

shssoichiro picture shssoichiro  路  4Comments

paulvt picture paulvt  路  4Comments

sphinxc0re picture sphinxc0re  路  3Comments