Add element.
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
use std::path::Path;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::IElement;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub(crate) enum RenderElement {}
|
||||
|
||||
impl RenderElement {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
config: &Config,
|
||||
output_directory: D,
|
||||
output_file: F,
|
||||
element: &IElement,
|
||||
) -> Result<RenderElement, CustomError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,14 @@ use crate::config::Config;
|
||||
use crate::error::CustomError;
|
||||
use crate::intermediate::ISection;
|
||||
|
||||
use super::RenderElement;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(rename = "section")]
|
||||
pub(crate) struct RenderSection {}
|
||||
pub(crate) struct RenderSection {
|
||||
children: Vec<RenderElement>,
|
||||
}
|
||||
|
||||
impl RenderSection {
|
||||
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
|
||||
@@ -18,6 +22,12 @@ impl RenderSection {
|
||||
output_file: F,
|
||||
section: &ISection,
|
||||
) -> Result<RenderSection, CustomError> {
|
||||
Ok(RenderSection {})
|
||||
let children = section
|
||||
.children
|
||||
.iter()
|
||||
.map(|obj| RenderElement::new(config, &output_directory, &output_file, obj))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
|
||||
Ok(RenderSection { children })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user