diff options
author | Philipp Korber <philippkorber@gmail.com> | 2018-11-22 20:22:23 +0100 |
---|---|---|
committer | Philipp Korber <philippkorber@gmail.com> | 2018-11-22 20:22:23 +0100 |
commit | 55482f880cfa67e68e52e5937f36251e886c137c (patch) | |
tree | 6092677fac3b5422433188b99b098a66d029f563 /template/src/handlebars.rs | |
parent | e0cdb9dbae5649b29753232bed9136389b940e23 (diff) |
fix(examples) made template example usable again
Diffstat (limited to 'template/src/handlebars.rs')
-rw-r--r-- | template/src/handlebars.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/template/src/handlebars.rs b/template/src/handlebars.rs index 2d06a31..370e649 100644 --- a/template/src/handlebars.rs +++ b/template/src/handlebars.rs @@ -11,6 +11,14 @@ use super::{ serde_impl }; +//TODO[FEAT] add custom engine config section to loading +// e.g. something like: +// ``` +// [engine] +// load_partial = "../partials/baseh.html" +// ``` +// +// Just specific to each engine. pub struct Handlebars { @@ -20,6 +28,25 @@ pub struct Handlebars { impl Handlebars { + pub fn new() -> Self { + Handlebars { + inner: hbs::Handlebars::new(), + name_counter: 0 + } + } + + pub fn inner(&self) -> &hbs::Handlebars { + &self.inner + } + + /// Provides mutable access to the underling handlebars instance. + /// + /// This can be used to e.g. add partials (in the future the template + /// file will have a custom config section but currently it doesn't). + pub fn inner_mut(&mut self) -> &mut hbs::Handlebars { + &mut self.inner + } + fn next_body_template_name(&mut self) -> String { let name = format!("body_{}", self.name_counter); self.name_counter += 1; |