Add basic templates for plain list.
This commit is contained in:
parent
5bbb12327b
commit
62ffc76376
@ -1 +1,6 @@
|
|||||||
plain_list
|
{@select key=.list_type}
|
||||||
|
{@eq value="unordered"}<ul>{#.children}{>plain_list_item/}{/.children}</ul>{/eq}
|
||||||
|
{@eq value="ordered"}<ol>{#.children}{>plain_list_item/}{/.children}</ol>{/eq}
|
||||||
|
{@eq value="descriptive"}<dl>{#.children}{>plain_list_item/}{/.children}</dl>{/eq}
|
||||||
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized list type {.list_type}.{/none}
|
||||||
|
{/select}
|
||||||
|
6
default_environment/templates/html/plain_list_item.dust
Normal file
6
default_environment/templates/html/plain_list_item.dust
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{@select key=list_type}
|
||||||
|
{@eq value="unordered"}<li></li>{/eq}
|
||||||
|
{@eq value="ordered"}<li></li>{/eq}
|
||||||
|
{@eq value="descriptive"}<dt></dt><dd></dd>{/eq}
|
||||||
|
{@none}{!TODO: make this panic!}ERROR: Unrecognized list type {.list_type}.{/none}
|
||||||
|
{/select}
|
@ -36,6 +36,7 @@ mod org_macro;
|
|||||||
mod paragraph;
|
mod paragraph;
|
||||||
mod plain_link;
|
mod plain_link;
|
||||||
mod plain_list;
|
mod plain_list;
|
||||||
|
mod plain_list_item;
|
||||||
mod plain_text;
|
mod plain_text;
|
||||||
mod planning;
|
mod planning;
|
||||||
mod property_drawer;
|
mod property_drawer;
|
||||||
|
@ -6,10 +6,15 @@ use crate::config::Config;
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::intermediate::IPlainList;
|
use crate::intermediate::IPlainList;
|
||||||
|
|
||||||
|
use super::plain_list_item::RenderPlainListItem;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
#[serde(rename = "plain_list")]
|
#[serde(rename = "plain_list")]
|
||||||
pub(crate) struct RenderPlainList {}
|
pub(crate) struct RenderPlainList {
|
||||||
|
list_type: String,
|
||||||
|
children: Vec<RenderPlainListItem>,
|
||||||
|
}
|
||||||
|
|
||||||
impl RenderPlainList {
|
impl RenderPlainList {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
@ -18,6 +23,27 @@ impl RenderPlainList {
|
|||||||
output_file: &Path,
|
output_file: &Path,
|
||||||
original: &IPlainList,
|
original: &IPlainList,
|
||||||
) -> Result<RenderPlainList, CustomError> {
|
) -> Result<RenderPlainList, CustomError> {
|
||||||
Ok(RenderPlainList {})
|
let list_type = match original.list_type {
|
||||||
|
organic::types::PlainListType::Unordered => "unordered".to_owned(),
|
||||||
|
organic::types::PlainListType::Ordered => "ordered".to_owned(),
|
||||||
|
organic::types::PlainListType::Descriptive => "descriptive".to_owned(),
|
||||||
|
};
|
||||||
|
let children = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
for obj in original.children.iter() {
|
||||||
|
ret.push(RenderPlainListItem::new(
|
||||||
|
config,
|
||||||
|
&output_directory,
|
||||||
|
&output_file,
|
||||||
|
obj,
|
||||||
|
)?);
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(RenderPlainList {
|
||||||
|
list_type,
|
||||||
|
children,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
src/context/plain_list_item.rs
Normal file
23
src/context/plain_list_item.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
|
use crate::error::CustomError;
|
||||||
|
use crate::intermediate::IPlainListItem;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
#[serde(rename = "plain_list_item")]
|
||||||
|
pub(crate) struct RenderPlainListItem {}
|
||||||
|
|
||||||
|
impl RenderPlainListItem {
|
||||||
|
pub(crate) fn new(
|
||||||
|
config: &Config,
|
||||||
|
output_directory: &Path,
|
||||||
|
output_file: &Path,
|
||||||
|
original: &IPlainListItem,
|
||||||
|
) -> Result<RenderPlainListItem, CustomError> {
|
||||||
|
Ok(RenderPlainListItem {})
|
||||||
|
}
|
||||||
|
}
|
@ -37,6 +37,7 @@ mod page;
|
|||||||
mod paragraph;
|
mod paragraph;
|
||||||
mod plain_link;
|
mod plain_link;
|
||||||
mod plain_list;
|
mod plain_list;
|
||||||
|
mod plain_list_item;
|
||||||
mod plain_text;
|
mod plain_text;
|
||||||
mod planning;
|
mod planning;
|
||||||
mod property_drawer;
|
mod property_drawer;
|
||||||
@ -98,6 +99,7 @@ pub(crate) use page::BlogPostPage;
|
|||||||
pub(crate) use paragraph::IParagraph;
|
pub(crate) use paragraph::IParagraph;
|
||||||
pub(crate) use plain_link::IPlainLink;
|
pub(crate) use plain_link::IPlainLink;
|
||||||
pub(crate) use plain_list::IPlainList;
|
pub(crate) use plain_list::IPlainList;
|
||||||
|
pub(crate) use plain_list_item::IPlainListItem;
|
||||||
pub(crate) use plain_text::IPlainText;
|
pub(crate) use plain_text::IPlainText;
|
||||||
pub(crate) use planning::IPlanning;
|
pub(crate) use planning::IPlanning;
|
||||||
pub(crate) use property_drawer::IPropertyDrawer;
|
pub(crate) use property_drawer::IPropertyDrawer;
|
||||||
|
@ -1,15 +1,30 @@
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
|
|
||||||
use super::registry::Registry;
|
use super::registry::Registry;
|
||||||
|
use super::IPlainListItem;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct IPlainList {}
|
pub(crate) struct IPlainList {
|
||||||
|
pub(crate) list_type: organic::types::PlainListType,
|
||||||
|
pub(crate) children: Vec<IPlainListItem>,
|
||||||
|
}
|
||||||
|
|
||||||
impl IPlainList {
|
impl IPlainList {
|
||||||
pub(crate) async fn new<'parse>(
|
pub(crate) async fn new<'parse>(
|
||||||
registry: &mut Registry<'parse>,
|
registry: &mut Registry<'parse>,
|
||||||
plain_list: &organic::types::PlainList<'parse>,
|
plain_list: &organic::types::PlainList<'parse>,
|
||||||
) -> Result<IPlainList, CustomError> {
|
) -> Result<IPlainList, CustomError> {
|
||||||
Ok(IPlainList {})
|
let children = {
|
||||||
|
let mut ret = Vec::new();
|
||||||
|
for obj in plain_list.children.iter() {
|
||||||
|
ret.push(IPlainListItem::new(registry, obj).await?);
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(IPlainList {
|
||||||
|
list_type: plain_list.list_type,
|
||||||
|
children,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
src/intermediate/plain_list_item.rs
Normal file
15
src/intermediate/plain_list_item.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
use crate::error::CustomError;
|
||||||
|
|
||||||
|
use super::registry::Registry;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub(crate) struct IPlainListItem {}
|
||||||
|
|
||||||
|
impl IPlainListItem {
|
||||||
|
pub(crate) async fn new<'parse>(
|
||||||
|
registry: &mut Registry<'parse>,
|
||||||
|
plain_list_item: &organic::types::PlainListItem<'parse>,
|
||||||
|
) -> Result<IPlainListItem, CustomError> {
|
||||||
|
Ok(IPlainListItem {})
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user