More early tera fns and mention limitation of shortcodes in docs

This commit is contained in:
Vincent Prouillet 2019-01-17 18:29:18 +01:00
parent 83472a53d7
commit 1b4cfd49d0
2 changed files with 9 additions and 5 deletions

View file

@ -339,20 +339,20 @@ impl Site {
"load_data",
global_fns::make_load_data(self.content_path.clone(), self.base_path.clone()),
);
self.tera.register_function("trans", global_fns::make_trans(self.config.clone()));
self.tera.register_function(
"get_taxonomy_url",
global_fns::make_get_taxonomy_url(&self.taxonomies),
);
}
pub fn register_tera_global_fns(&mut self) {
self.tera.register_function("trans", global_fns::make_trans(self.config.clone()));
self.tera.register_function("get_page", global_fns::make_get_page(&self.library));
self.tera.register_function("get_section", global_fns::make_get_section(&self.library));
self.tera.register_function(
"get_taxonomy",
global_fns::make_get_taxonomy(&self.taxonomies, &self.library),
);
self.tera.register_function(
"get_taxonomy_url",
global_fns::make_get_taxonomy_url(&self.taxonomies),
);
}
/// Add a page to the site

View file

@ -36,6 +36,10 @@ That's it, Zola will now recognise this template as a shortcode named `youtube`
The markdown renderer will wrap an inline HTML node like `<a>` or `<span>` into a paragraph. If you want to disable that,
simply wrap your shortcode in a `div`.
Shortcodes are rendered before parsing the markdown so it doesn't have access to the table of contents. Because of that,
you also cannot use the `get_page`/`get_section`/`get_taxonomy` global function. It might work while running `zola serve` because
it has been loaded but it will fail during `zola build`.
## Using shortcodes
There are two kinds of shortcodes: