Figured out how to get a value using to_string()
				
					
				
			Figured out how to get a value using `to_string()` but serde_json's `to_string()` is wrapping a string in quotes. I think I want to implement my own trait to support custom logic for rendering values.
This commit is contained in:
		
							parent
							
								
									265afe7eeb
								
							
						
					
					
						commit
						af5122ab9f
					
				| @ -46,6 +46,7 @@ impl<'a> DustRenderer<'a> { | ||||
|     pub fn render<C>(&self, name: &str, context: &C) -> Result<String, RenderError> | ||||
|     where | ||||
|         C: Index<&'a str>, | ||||
|         <C as std::ops::Index<&'a str>>::Output: std::string::ToString, | ||||
|     { | ||||
|         let main_template = match self.templates.get(name) { | ||||
|             Some(tmpl) => tmpl, | ||||
| @ -61,6 +62,7 @@ impl<'a> DustRenderer<'a> { | ||||
|     fn render_template<C>(&self, template: &Template, context: &C) -> Result<String, RenderError> | ||||
|     where | ||||
|         C: Index<&'a str>, | ||||
|         <C as std::ops::Index<&'a str>>::Output: std::string::ToString, | ||||
|     { | ||||
|         let mut output = String::new(); | ||||
|         for elem in &template.contents.elements { | ||||
| @ -77,10 +79,14 @@ impl<'a> DustRenderer<'a> { | ||||
|     fn render_tag<C>(&self, tag: &DustTag, context: &C) -> Result<String, RenderError> | ||||
|     where | ||||
|         C: Index<&'a str>, | ||||
|         <C as std::ops::Index<&'a str>>::Output: std::string::ToString, | ||||
|     { | ||||
|         match tag { | ||||
|             DustTag::DTComment(comment) => (), | ||||
|             DustTag::DTReference(reference) => (), | ||||
|             DustTag::DTReference(reference) => { | ||||
|                 let val = context.index("name"); | ||||
|                 return Ok(val.to_string()); | ||||
|             } | ||||
|             _ => (), // TODO: Implement the rest
 | ||||
|         } | ||||
|         Ok("".to_owned()) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander