Render the table groups.
This commit is contained in:
parent
fa2dd96f78
commit
95d4ee7080
@ -1 +1,5 @@
|
|||||||
<table class="org_table"><tbody>{#.children}{>table_row/}{/.children}</tbody></table>
|
<table class="org_table">{#.children}{@select key=.type}
|
||||||
|
{@eq value="head"}{>table_head/}{/eq}
|
||||||
|
{@eq value="body"}{>table_body/}{/eq}
|
||||||
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized type {.type}.{/none}
|
||||||
|
{/select}{/.children}</table>
|
||||||
|
1
default_environment/templates/html/table_body.dust
Normal file
1
default_environment/templates/html/table_body.dust
Normal file
@ -0,0 +1 @@
|
|||||||
|
<tbody>{#.children}{>table_row/}{/.children}</tbody>
|
1
default_environment/templates/html/table_head.dust
Normal file
1
default_environment/templates/html/table_head.dust
Normal file
@ -0,0 +1 @@
|
|||||||
|
<thead>{#.children}{>table_head_row/}{/.children}</thead>
|
1
default_environment/templates/html/table_head_cell.dust
Normal file
1
default_environment/templates/html/table_head_cell.dust
Normal file
@ -0,0 +1 @@
|
|||||||
|
<th scope="col">{#.children}{>object/}{/.children}</th>
|
1
default_environment/templates/html/table_head_row.dust
Normal file
1
default_environment/templates/html/table_head_row.dust
Normal file
@ -0,0 +1 @@
|
|||||||
|
<tr>{#.children}{>table_head_cell/}{/.children}</tr>
|
@ -59,6 +59,7 @@ mod subscript;
|
|||||||
mod superscript;
|
mod superscript;
|
||||||
mod table;
|
mod table;
|
||||||
mod table_cell;
|
mod table_cell;
|
||||||
|
mod table_group;
|
||||||
mod table_row;
|
mod table_row;
|
||||||
mod target;
|
mod target;
|
||||||
mod timestamp;
|
mod timestamp;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::render_context::RenderContext;
|
use super::render_context::RenderContext;
|
||||||
|
use super::table_group::RenderTableGroup;
|
||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::ITable;
|
use crate::intermediate::ITable;
|
||||||
|
use crate::intermediate::ITableGroup;
|
||||||
|
|
||||||
use super::macros::render;
|
use super::macros::render;
|
||||||
use super::table_row::RenderTableRow;
|
use super::table_row::RenderTableRow;
|
||||||
@ -11,15 +13,29 @@ use super::table_row::RenderTableRow;
|
|||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
#[serde(rename = "table")]
|
#[serde(rename = "table")]
|
||||||
pub(crate) struct RenderTable {
|
pub(crate) struct RenderTable {
|
||||||
children: Vec<RenderTableRow>,
|
children: Vec<RenderTableGroup>,
|
||||||
post_blank: organic::types::PostBlank,
|
post_blank: organic::types::PostBlank,
|
||||||
}
|
}
|
||||||
|
|
||||||
render!(RenderTable, ITable, original, render_context, {
|
render!(RenderTable, ITable, original, render_context, {
|
||||||
let children = {
|
let children = {
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
for obj in original.children.iter() {
|
for group in original.children.iter() {
|
||||||
ret.push(RenderTableRow::new(render_context.clone(), obj)?);
|
let mut rows = Vec::new();
|
||||||
|
match group {
|
||||||
|
ITableGroup::Head(irows) => {
|
||||||
|
for obj in irows {
|
||||||
|
rows.push(RenderTableRow::new(render_context.clone(), obj)?);
|
||||||
|
}
|
||||||
|
ret.push(RenderTableGroup::Head { children: rows });
|
||||||
|
}
|
||||||
|
ITableGroup::Body(irows) => {
|
||||||
|
for obj in irows {
|
||||||
|
rows.push(RenderTableRow::new(render_context.clone(), obj)?);
|
||||||
|
}
|
||||||
|
ret.push(RenderTableGroup::Body { children: rows });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
};
|
};
|
||||||
|
12
src/context/table_group.rs
Normal file
12
src/context/table_group.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
use super::table_row::RenderTableRow;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
pub(crate) enum RenderTableGroup {
|
||||||
|
#[serde(rename = "head")]
|
||||||
|
Head { children: Vec<RenderTableRow> },
|
||||||
|
|
||||||
|
#[serde(rename = "body")]
|
||||||
|
Body { children: Vec<RenderTableRow> },
|
||||||
|
}
|
@ -127,6 +127,7 @@ pub(crate) use subscript::ISubscript;
|
|||||||
pub(crate) use superscript::ISuperscript;
|
pub(crate) use superscript::ISuperscript;
|
||||||
pub(crate) use table::ITable;
|
pub(crate) use table::ITable;
|
||||||
pub(crate) use table_cell::ITableCell;
|
pub(crate) use table_cell::ITableCell;
|
||||||
|
pub(crate) use table_group::ITableGroup;
|
||||||
pub(crate) use table_row::ITableRow;
|
pub(crate) use table_row::ITableRow;
|
||||||
pub(crate) use target::ITarget;
|
pub(crate) use target::ITarget;
|
||||||
pub(crate) use timestamp::ITimestamp;
|
pub(crate) use timestamp::ITimestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user