diff --git a/src/lib.rs b/src/lib.rs index 6e79fbb2..a84a891a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,12 +28,10 @@ mod site; mod markdown; mod section; mod pagination; -/// Additional filters for Tera -mod filters; -/// Global fns for Tera -mod global_fns; +// Filters, Global Fns and default instance of Tera +mod templates; -pub use site::{Site, GUTENBERG_TERA}; +pub use site::{Site}; pub use config::{Config, get_config}; pub use front_matter::{FrontMatter, split_content, SortBy}; pub use page::{Page, populate_previous_and_next_pages}; diff --git a/src/markdown.rs b/src/markdown.rs index 9be64a7d..f32cf898 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -340,7 +340,7 @@ pub fn markdown_to_html(content: &str, permalinks: &HashMap, ter mod tests { use std::collections::HashMap; - use site::GUTENBERG_TERA; + use templates::GUTENBERG_TERA; use tera::Tera; use config::Config; diff --git a/src/site.rs b/src/site.rs index 46c20f7a..ee625000 100644 --- a/src/site.rs +++ b/src/site.rs @@ -15,29 +15,9 @@ use pagination::Paginator; use utils::{create_file, create_directory}; use section::{Section}; use front_matter::{SortBy}; -use filters; -use global_fns; +use templates::{GUTENBERG_TERA, filters, 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 /// via refresh to the url given fn render_alias(url: &str, tera: &Tera) -> Result { diff --git a/src/templates/anchor-link.html b/src/templates/builtins/anchor-link.html similarity index 100% rename from src/templates/anchor-link.html rename to src/templates/builtins/anchor-link.html diff --git a/src/templates/internal/alias.html b/src/templates/builtins/internal/alias.html similarity index 100% rename from src/templates/internal/alias.html rename to src/templates/builtins/internal/alias.html diff --git a/src/templates/robots.txt b/src/templates/builtins/robots.txt similarity index 100% rename from src/templates/robots.txt rename to src/templates/builtins/robots.txt diff --git a/src/templates/rss.xml b/src/templates/builtins/rss.xml similarity index 100% rename from src/templates/rss.xml rename to src/templates/builtins/rss.xml diff --git a/src/templates/shortcodes/gist.html b/src/templates/builtins/shortcodes/gist.html similarity index 100% rename from src/templates/shortcodes/gist.html rename to src/templates/builtins/shortcodes/gist.html diff --git a/src/templates/shortcodes/vimeo.html b/src/templates/builtins/shortcodes/vimeo.html similarity index 100% rename from src/templates/shortcodes/vimeo.html rename to src/templates/builtins/shortcodes/vimeo.html diff --git a/src/templates/shortcodes/youtube.html b/src/templates/builtins/shortcodes/youtube.html similarity index 100% rename from src/templates/shortcodes/youtube.html rename to src/templates/builtins/shortcodes/youtube.html diff --git a/src/templates/sitemap.xml b/src/templates/builtins/sitemap.xml similarity index 100% rename from src/templates/sitemap.xml rename to src/templates/builtins/sitemap.xml diff --git a/src/filters.rs b/src/templates/filters.rs similarity index 100% rename from src/filters.rs rename to src/templates/filters.rs diff --git a/src/global_fns.rs b/src/templates/global_fns.rs similarity index 100% rename from src/global_fns.rs rename to src/templates/global_fns.rs diff --git a/src/templates/mod.rs b/src/templates/mod.rs new file mode 100644 index 00000000..11e50776 --- /dev/null +++ b/src/templates/mod.rs @@ -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 + }; +}