| Crates.io | file_check_macro |
| lib.rs | file_check_macro |
| version | 0.1.0 |
| created_at | 2023-11-27 09:56:35.662576+00 |
| updated_at | 2023-11-27 09:56:35.662576+00 |
| description | A macro for checking the presence of a template file at compile time. E.g. for Tera templates |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1050292 |
| size | 2,828 |
Use this macro to get compile time errors if a template doesn't exist.
The macro in this crate, generate_template, takes a string slice (&str). It checks that the file in the string exists on disk in src, and generates a const TEMPLATE:&str = <your string slice;>.
Usage:
This:
generate_template!("path/to/my/template.tera");
Is the same as:
const TEMPLATE:&str = "path/to/my/template.tera";
But with a check that the file exists at:
src/path/to/my/template.tera
Note the prepended src.
The use case is this:
templates tree like some kind of blithering idiot.