natter/src/context/section.rs

28 lines
640 B
Rust

use serde::Serialize;
use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::ISection;
use super::macros::render;
use super::RenderElement;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "section")]
pub(crate) struct RenderSection {
children: Vec<RenderElement>,
}
render!(RenderSection, ISection, original, render_context, {
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(RenderElement::new(render_context.clone(), obj)?);
}
ret
};
Ok(RenderSection { children })
});