Starting to create the renderer integrations.
These are the layer directly over dust which can be used by anything, not just blog posts.
This commit is contained in:
		
							parent
							
								
									5f34cb2dd5
								
							
						
					
					
						commit
						24bac982f1
					
				| @ -3,6 +3,7 @@ use std::path::PathBuf; | ||||
| use crate::blog_post::convert_blog_post_to_render_context; | ||||
| use crate::blog_post::BlogPost; | ||||
| use crate::error::CustomError; | ||||
| use crate::render::DusterRenderer; | ||||
| 
 | ||||
| pub(crate) struct SiteRenderer { | ||||
|     pub(crate) output_directory: PathBuf, | ||||
| @ -16,6 +17,8 @@ impl SiteRenderer { | ||||
|             println!("{}", serde_json::to_string(&render_context)?); | ||||
|         } | ||||
| 
 | ||||
|         let mut renderer_integration = DusterRenderer {}; | ||||
| 
 | ||||
|         Ok(()) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -12,6 +12,7 @@ mod cli; | ||||
| mod command; | ||||
| mod config; | ||||
| mod error; | ||||
| mod render; | ||||
| 
 | ||||
| fn main() -> Result<ExitCode, CustomError> { | ||||
|     let rt = tokio::runtime::Runtime::new()?; | ||||
|  | ||||
							
								
								
									
										24
									
								
								src/render/duster_renderer.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/render/duster_renderer.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| use super::renderer_integration::RendererIntegration; | ||||
| 
 | ||||
| pub(crate) struct DusterRenderer {} | ||||
| 
 | ||||
| impl RendererIntegration for DusterRenderer { | ||||
|     fn load_templates<I, P>(&mut self, dust_templates: I) -> Result<(), crate::error::CustomError> | ||||
|     where | ||||
|         I: Iterator<Item = P>, | ||||
|         P: Into<std::path::PathBuf>, | ||||
|     { | ||||
|         todo!() | ||||
|     } | ||||
| 
 | ||||
|     fn render<P>( | ||||
|         &self, | ||||
|         context: &str, | ||||
|         build_directory: P, | ||||
|     ) -> Result<String, crate::error::CustomError> | ||||
|     where | ||||
|         P: AsRef<std::path::Path>, | ||||
|     { | ||||
|         todo!() | ||||
|     } | ||||
| } | ||||
							
								
								
									
										3
									
								
								src/render/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/render/mod.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| mod duster_renderer; | ||||
| mod renderer_integration; | ||||
| pub(crate) use duster_renderer::DusterRenderer; | ||||
							
								
								
									
										15
									
								
								src/render/renderer_integration.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/render/renderer_integration.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| use std::path::Path; | ||||
| use std::path::PathBuf; | ||||
| 
 | ||||
| use crate::error::CustomError; | ||||
| 
 | ||||
| pub trait RendererIntegration { | ||||
|     fn load_templates<I, P>(&mut self, dust_templates: I) -> Result<(), CustomError> | ||||
|     where | ||||
|         I: Iterator<Item = P>, | ||||
|         P: Into<PathBuf>; | ||||
| 
 | ||||
|     fn render<P>(&self, context: &str, build_directory: P) -> Result<String, CustomError> | ||||
|     where | ||||
|         P: AsRef<Path>; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander