You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want my program to be a single-file executable program in the end. To do this I need to embed the template into the binary product. Currently, I use include_dir!. But how do I register the template to Tera?
My code is work:
use include_dir::include_dir;use tera::Tera;staticEMBED_TEMPLATE: include_dir::Dir = include_dir!("templates");pubfnmake_template() -> Tera{letmut tera = Tera::default();for file inEMBED_TEMPLATE.files(){let name = match file.path().to_str(){Some(name) => name,None => continue,};let content = match file.contents_utf8(){Some(content) => content,None => continue,};ifletErr(_) = tera.add_raw_template(name, content){
std::process::exit(1);}}
tera
}
I can't guarantee the correct dependencies unless I specify the order manually.
When I use {% extend layout.html %} in index.html,the index.html depends on layout.html. But index.html is registered before layout.html in my code. This causes Tera to not be able to find layout.html when parsing index.html.
Is there any way to solve this problem?
The text was updated successfully, but these errors were encountered:
I want my program to be a single-file executable program in the end. To do this I need to embed the template into the binary product. Currently, I use
include_dir!
. But how do I register the template to Tera?My code is work:
I can't guarantee the correct dependencies unless I specify the order manually.
When I use
{% extend layout.html %}
inindex.html
,theindex.html
depends onlayout.html
. Butindex.html
is registered beforelayout.html
in my code. This causes Tera to not be able to findlayout.html
when parsingindex.html
.Is there any way to solve this problem?
The text was updated successfully, but these errors were encountered: