Browse Source

Move all tera stuff into a templates mod

index-subcmd
Vincent Prouillet 7 years ago
parent
commit
72c626ee55
14 changed files with 29 additions and 28 deletions
  1. +3
    -5
      src/lib.rs
  2. +1
    -1
      src/markdown.rs
  3. +2
    -22
      src/site.rs
  4. +0
    -0
      src/templates/builtins/anchor-link.html
  5. +0
    -0
      src/templates/builtins/internal/alias.html
  6. +0
    -0
      src/templates/builtins/robots.txt
  7. +0
    -0
      src/templates/builtins/rss.xml
  8. +0
    -0
      src/templates/builtins/shortcodes/gist.html
  9. +0
    -0
      src/templates/builtins/shortcodes/vimeo.html
  10. +0
    -0
      src/templates/builtins/shortcodes/youtube.html
  11. +0
    -0
      src/templates/builtins/sitemap.xml
  12. +0
    -0
      src/templates/filters.rs
  13. +0
    -0
      src/templates/global_fns.rs
  14. +23
    -0
      src/templates/mod.rs

+ 3
- 5
src/lib.rs View File

@@ -28,12 +28,10 @@ mod site;
mod markdown; mod markdown;
mod section; mod section;
mod pagination; 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 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};


+ 1
- 1
src/markdown.rs View File

@@ -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;


+ 2
- 22
src/site.rs View File

@@ -15,28 +15,8 @@ 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 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
};
}
use templates::{GUTENBERG_TERA, filters, global_fns};



/// 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


src/templates/anchor-link.html → src/templates/builtins/anchor-link.html View File


src/templates/internal/alias.html → src/templates/builtins/internal/alias.html View File


src/templates/robots.txt → src/templates/builtins/robots.txt View File


src/templates/rss.xml → src/templates/builtins/rss.xml View File


src/templates/shortcodes/gist.html → src/templates/builtins/shortcodes/gist.html View File


src/templates/shortcodes/vimeo.html → src/templates/builtins/shortcodes/vimeo.html View File


src/templates/shortcodes/youtube.html → src/templates/builtins/shortcodes/youtube.html View File


src/templates/sitemap.xml → src/templates/builtins/sitemap.xml View File


src/filters.rs → src/templates/filters.rs View File


src/global_fns.rs → src/templates/global_fns.rs View File


+ 23
- 0
src/templates/mod.rs View 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…
Cancel
Save