Implemented the json stringify and parse filters.

This commit is contained in:
Tom Alexander
2020-05-23 18:14:23 -04:00
parent 624c83b680
commit e22bffd2ba
3 changed files with 39 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ use std::fmt;
pub enum RenderError {
Generic(String),
TemplateNotFound(String),
InvalidJson(String),
}
#[derive(PartialEq)]
@@ -27,6 +28,11 @@ impl fmt::Display for RenderError {
RenderError::TemplateNotFound(name) => {
write!(f, "No template named {} in context", name)
}
RenderError::InvalidJson(invalid_json) => write!(
f,
"Attempted to parse the following invalid JSON: {}",
invalid_json
),
}
}
}
@@ -38,6 +44,11 @@ impl fmt::Debug for RenderError {
RenderError::TemplateNotFound(name) => {
write!(f, "No template named {} in context", name)
}
RenderError::InvalidJson(invalid_json) => write!(
f,
"Attempted to parse the following invalid JSON: {}",
invalid_json
),
}
}
}