Move all tera stuff into a templates mod
This commit is contained in:
parent
2fb4e2b01d
commit
72c626ee55
|
@ -28,12 +28,10 @@ mod site;
|
||||||
mod markdown;
|
mod markdown;
|
||||||
mod section;
|
mod section;
|
||||||
mod pagination;
|
mod pagination;
|
||||||
/// Additional filters for Tera
|
// Filters, Global Fns and default instance of Tera
|
||||||
mod filters;
|
mod templates;
|
||||||
/// Global fns for Tera
|
|
||||||
mod global_fns;
|
|
||||||
|
|
||||||
pub use site::{Site, GUTENBERG_TERA};
|
pub use site::{Site};
|
||||||
pub use config::{Config, get_config};
|
pub use config::{Config, get_config};
|
||||||
pub use front_matter::{FrontMatter, split_content, SortBy};
|
pub use front_matter::{FrontMatter, split_content, SortBy};
|
||||||
pub use page::{Page, populate_previous_and_next_pages};
|
pub use page::{Page, populate_previous_and_next_pages};
|
||||||
|
|
|
@ -340,7 +340,7 @@ pub fn markdown_to_html(content: &str, permalinks: &HashMap<String, String>, ter
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use site::GUTENBERG_TERA;
|
use templates::GUTENBERG_TERA;
|
||||||
use tera::Tera;
|
use tera::Tera;
|
||||||
|
|
||||||
use config::Config;
|
use config::Config;
|
||||||
|
|
22
src/site.rs
22
src/site.rs
|
@ -15,29 +15,9 @@ use pagination::Paginator;
|
||||||
use utils::{create_file, create_directory};
|
use utils::{create_file, create_directory};
|
||||||
use section::{Section};
|
use section::{Section};
|
||||||
use front_matter::{SortBy};
|
use front_matter::{SortBy};
|
||||||
use filters;
|
use templates::{GUTENBERG_TERA, filters, global_fns};
|
||||||
use global_fns;
|
|
||||||
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
pub static ref GUTENBERG_TERA: Tera = {
|
|
||||||
let mut tera = Tera::default();
|
|
||||||
tera.add_raw_templates(vec![
|
|
||||||
("rss.xml", include_str!("templates/rss.xml")),
|
|
||||||
("sitemap.xml", include_str!("templates/sitemap.xml")),
|
|
||||||
("robots.txt", include_str!("templates/robots.txt")),
|
|
||||||
("anchor-link.html", include_str!("templates/anchor-link.html")),
|
|
||||||
|
|
||||||
("shortcodes/youtube.html", include_str!("templates/shortcodes/youtube.html")),
|
|
||||||
("shortcodes/vimeo.html", include_str!("templates/shortcodes/vimeo.html")),
|
|
||||||
("shortcodes/gist.html", include_str!("templates/shortcodes/gist.html")),
|
|
||||||
|
|
||||||
("internal/alias.html", include_str!("templates/internal/alias.html")),
|
|
||||||
]).unwrap();
|
|
||||||
tera
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Renders the `internal/alias.html` template that will redirect
|
/// Renders the `internal/alias.html` template that will redirect
|
||||||
/// via refresh to the url given
|
/// via refresh to the url given
|
||||||
fn render_alias(url: &str, tera: &Tera) -> Result<String> {
|
fn render_alias(url: &str, tera: &Tera) -> Result<String> {
|
||||||
|
|
23
src/templates/mod.rs
Normal file
23
src/templates/mod.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use tera::Tera;
|
||||||
|
|
||||||
|
pub mod filters;
|
||||||
|
pub mod global_fns;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref GUTENBERG_TERA: Tera = {
|
||||||
|
let mut tera = Tera::default();
|
||||||
|
tera.add_raw_templates(vec![
|
||||||
|
("rss.xml", include_str!("builtins/rss.xml")),
|
||||||
|
("sitemap.xml", include_str!("builtins/sitemap.xml")),
|
||||||
|
("robots.txt", include_str!("builtins/robots.txt")),
|
||||||
|
("anchor-link.html", include_str!("builtins/anchor-link.html")),
|
||||||
|
|
||||||
|
("shortcodes/youtube.html", include_str!("builtins/shortcodes/youtube.html")),
|
||||||
|
("shortcodes/vimeo.html", include_str!("builtins/shortcodes/vimeo.html")),
|
||||||
|
("shortcodes/gist.html", include_str!("builtins/shortcodes/gist.html")),
|
||||||
|
|
||||||
|
("internal/alias.html", include_str!("builtins/internal/alias.html")),
|
||||||
|
]).unwrap();
|
||||||
|
tera
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue