You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

context.rs 1006B

1234567891011121314151617181920212223242526272829303132333435363738
  1. use std::collections::HashMap;
  2. use tera::{Tera, Context};
  3. use front_matter::InsertAnchor;
  4. use config::Config;
  5. /// All the information from the gutenberg site that is needed to render HTML from markdown
  6. #[derive(Debug)]
  7. pub struct RenderContext<'a> {
  8. pub tera: &'a Tera,
  9. pub config: &'a Config,
  10. pub tera_context: Context,
  11. pub current_page_permalink: &'a str,
  12. pub permalinks: &'a HashMap<String, String>,
  13. pub insert_anchor: InsertAnchor,
  14. }
  15. impl<'a> RenderContext<'a> {
  16. pub fn new(
  17. tera: &'a Tera,
  18. config: &'a Config,
  19. current_page_permalink: &'a str,
  20. permalinks: &'a HashMap<String, String>,
  21. insert_anchor: InsertAnchor,
  22. ) -> RenderContext<'a> {
  23. let mut tera_context = Context::new();
  24. tera_context.insert("config", config);
  25. RenderContext {
  26. tera,
  27. tera_context,
  28. current_page_permalink,
  29. permalinks,
  30. insert_anchor,
  31. config,
  32. }
  33. }
  34. }