Rocket: Cannot use Tera's template inheritance

Created on 6 Dec 2017  路  4Comments  路  Source: SergioBenitez/Rocket

If one is using Tera templates and there is any template that extends another, Rocket's launch fails throwing the following launch error:

Error: Failed to initialize Tera templating. => Template 'index' is inheriting from 'base.tera', which doesn't exist or isn't loaded. Error: Rocket failed to launch due to a failing fairing. thread 'main' panicked at 'launch fairing failure',

This error is thrown regardless of whether I am using any of the templates, so it probably has to do with the way the fairing is loading them?

Template inheritance is very useful for having several layouts/blocks and extended them to create page templates. See also: https://tera.netlify.com/docs/templates/#inheritance.

I am using Rocket (codege/contrib) 0.3.3 on Debian GNU/Linux testing.

question

Most helpful comment

When using .html.tera as extension as opposed to just .tera, everything works fine! Thanks!

I followed the guide on templating here, so it was not clear to me that a render of index means index.html.tera should exist. Maybe a note could be added or the explanation on extensions could be tweaked? (I overlooked the tera template example, sorry).

All 4 comments

It looks like you're asking for a template named "base.tera"; this would mean that you have a file named something like "base.tera.tera", which seems unlikely. You'll likely be able to resolve this by simply changing "base.tera" to "base".

@That results in:

    => Template 'index' is inheriting from 'base', which doesn't exist or isn't loaded.

So, unfortunately, that doesn't help. I was a bit confused by Tera just using index.html but Rocket (logically) insisting on the .tera extension because it needs to know what to do.

Without seeing your file system layout, I don't know what things should be called. Please see the tera templates examples for a concrete implementation.

When using .html.tera as extension as opposed to just .tera, everything works fine! Thanks!

I followed the guide on templating here, so it was not clear to me that a render of index means index.html.tera should exist. Maybe a note could be added or the explanation on extensions could be tweaked? (I overlooked the tera template example, sorry).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lambda-fairy picture lambda-fairy  路  4Comments

haheute picture haheute  路  4Comments

Turakar picture Turakar  路  4Comments

GoRustafari picture GoRustafari  路  3Comments

denysvitali picture denysvitali  路  3Comments