#Use of Tera templates within a module

1 messages · Page 1 of 1 (latest)

still vapor
#

I have a web application split into modules like this:

.
└── src/
    ├── routes/
    │   ├── about/
    │   │   └── mod.rs
    │   └── mod.rs
    ├── main.rs
    └── lib.rs

How can Tera templates be used in the module src/routes/about/mod.rs?

Trying to define Tera in src/routes/about/mod.rs like let mut tera = Tera::new("templates/**/*").unwrap(); leads to expected item, found 'let'.

The "about" module is also defined as pub mod or similar in src/routes/mod.rs and src/lib.rs

I am still completely new to Rust and in the process of rewriting a Python Django-based website in Rust so I may still have the Python mindset and miss some things.

normal totem
#

it might be beneficial to start from a working project and modify from there

#

you might have to watch out, when it comes to relative file paths, since the behavior might be different from Python...

relative paths are usually relative to the current working directory, ie. the dir where you do cargo run (not the file where they're written)

still vapor
#

Thanks