Combine the render traits into a single context_element file.
This commit is contained in:
parent
41ad6179d1
commit
c961cf7ab8
@ -1,4 +1,4 @@
|
|||||||
use super::renderable::Renderable;
|
use crate::parser::Filter;
|
||||||
use crate::renderer::errors::RenderError;
|
use crate::renderer::errors::RenderError;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
@ -7,3 +7,7 @@ pub trait ContextElement: Walkable + Renderable + Debug {}
|
|||||||
pub trait Walkable {
|
pub trait Walkable {
|
||||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, RenderError>;
|
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, RenderError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait Renderable {
|
||||||
|
fn render(&self, filters: &Vec<Filter>) -> Result<String, RenderError>;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
use crate::renderer::walkable::ContextElement;
|
use crate::renderer::context_element::ContextElement;
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
//! This module contains a renderer for a rust implementation of LinkedIn Dust
|
//! This module contains a renderer for a rust implementation of LinkedIn Dust
|
||||||
|
|
||||||
|
mod context_element;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod renderable;
|
|
||||||
mod renderer;
|
mod renderer;
|
||||||
mod walkable;
|
|
||||||
|
|
||||||
|
pub use context_element::ContextElement;
|
||||||
|
pub use context_element::Renderable;
|
||||||
|
pub use context_element::Walkable;
|
||||||
pub use errors::CompileError;
|
pub use errors::CompileError;
|
||||||
pub use errors::RenderError;
|
pub use errors::RenderError;
|
||||||
pub use renderable::Renderable;
|
|
||||||
pub use renderer::compile_template;
|
pub use renderer::compile_template;
|
||||||
pub use renderer::CompiledTemplate;
|
pub use renderer::CompiledTemplate;
|
||||||
pub use renderer::DustRenderer;
|
pub use renderer::DustRenderer;
|
||||||
pub use walkable::ContextElement;
|
|
||||||
pub use walkable::Walkable;
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
use crate::parser::Filter;
|
|
||||||
use crate::renderer::errors::RenderError;
|
|
||||||
|
|
||||||
pub trait Renderable {
|
|
||||||
fn render(&self, filters: &Vec<Filter>) -> Result<String, RenderError>;
|
|
||||||
}
|
|
@ -3,9 +3,9 @@ use crate::parser::Body;
|
|||||||
use crate::parser::DustTag;
|
use crate::parser::DustTag;
|
||||||
use crate::parser::Template;
|
use crate::parser::Template;
|
||||||
use crate::parser::TemplateElement;
|
use crate::parser::TemplateElement;
|
||||||
|
use crate::renderer::context_element::ContextElement;
|
||||||
use crate::renderer::errors::CompileError;
|
use crate::renderer::errors::CompileError;
|
||||||
use crate::renderer::errors::RenderError;
|
use crate::renderer::errors::RenderError;
|
||||||
use crate::renderer::walkable::ContextElement;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -114,8 +114,8 @@ fn walk_path<'a>(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::parser::Filter;
|
use crate::parser::Filter;
|
||||||
use crate::renderer::renderable::Renderable;
|
use crate::renderer::context_element::Renderable;
|
||||||
use crate::renderer::walkable::Walkable;
|
use crate::renderer::context_element::Walkable;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_walk_path() {
|
fn test_walk_path() {
|
||||||
|
Loading…
Reference in New Issue
Block a user