make parser take a reference to context
This commit is contained in:
parent
abb1178657
commit
f66b69ffc1
13
src/lib.rs
13
src/lib.rs
|
@ -1,24 +1,25 @@
|
|||
use roxy_core::roxy::Parse;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct TeraParser {
|
||||
#[derive(Debug)]
|
||||
pub struct TeraParser<'a> {
|
||||
pub tera: tera::Tera,
|
||||
context: tera::Context,
|
||||
context: &'a tera::Context,
|
||||
}
|
||||
|
||||
impl TeraParser {
|
||||
pub fn new(tera: tera::Tera, context: tera::Context) -> Self {
|
||||
impl<'a> TeraParser<'a> {
|
||||
pub fn new(tera: tera::Tera, context: &'a tera::Context) -> Self {
|
||||
Self { tera, context }
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for TeraParser {
|
||||
impl<'a> Parse for TeraParser<'a> {
|
||||
fn parse(&mut self, path: &str, src: &[u8], dst: &mut Vec<u8>) -> std::io::Result<()> {
|
||||
// TODO: This error is a hack
|
||||
let err = |e: tera::Error| {
|
||||
println!("{e:?}");
|
||||
std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string())
|
||||
};
|
||||
|
||||
let template = String::from_utf8_lossy(src).to_string();
|
||||
|
||||
self.tera
|
||||
|
|
Loading…
Reference in a new issue