Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/mrml-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,16 @@ pub mod mj_font;
pub mod mj_group;
pub mod mj_head;
pub mod mj_hero;
pub mod mj_html_attribute;
pub mod mj_html_attributes;
pub mod mj_image;
pub mod mj_include;
pub mod mj_navbar;
pub mod mj_navbar_link;
pub mod mj_preview;
pub mod mj_raw;
pub mod mj_section;
pub mod mj_selector;
pub mod mj_social;
pub mod mj_social_element;
pub mod mj_spacer;
Expand Down
5 changes: 3 additions & 2 deletions packages/mrml-core/src/mj_accordion/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'root> Render<'root> for Renderer<'root, MjAccordion, ()> {
fn render(&self, cursor: &mut RenderCursor) -> Result<(), Error> {
self.update_header(&mut cursor.header);

let tbody = Tag::tbody();
let tbody = Tag::tbody().set_html_attributes(self.context.header.html_attributes());
let table = Tag::table()
.add_style("width", "100%")
.add_style("border-collapse", "collapse")
Expand All @@ -100,7 +100,8 @@ impl<'root> Render<'root> for Renderer<'root, MjAccordion, ()> {
.maybe_add_style("font-family", self.attribute("font-family"))
.add_attribute("cellspacing", "0")
.add_attribute("cellpadding", "0")
.add_class("mj-accordion");
.add_class("mj-accordion")
.set_html_attributes(self.context.header.html_attributes());

table.render_open(&mut cursor.buffer)?;
tbody.render_open(&mut cursor.buffer)?;
Expand Down
15 changes: 10 additions & 5 deletions packages/mrml-core/src/mj_accordion_element/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,21 @@ impl<'root> Render<'root> for Renderer<'root, MjAccordionElement, MjAccordionEle
let input = Tag::new("input")
.add_attribute("type", "checkbox")
.add_class("mj-accordion-checkbox")
.add_style("display", "none");
let div = Tag::div();
.add_style("display", "none")
.set_html_attributes(self.context.header.html_attributes());
let div = Tag::div().set_html_attributes(self.context.header.html_attributes());
let label = Tag::new("label")
.add_class("mj-accordion-element")
.add_style("font-size", "13px")
.maybe_add_style("font-family", self.attribute("font-family"));
.maybe_add_style("font-family", self.attribute("font-family"))
.set_html_attributes(self.context.header.html_attributes());
let td = Tag::td()
.add_style("padding", "0px")
.maybe_add_style("background-color", self.attribute("background-color"));
let tr = Tag::tr().maybe_add_class(self.attribute("css-class"));
.maybe_add_style("background-color", self.attribute("background-color"))
.set_html_attributes(self.context.header.html_attributes());
let tr = Tag::tr()
.maybe_add_class(self.attribute("css-class"))
.set_html_attributes(self.context.header.html_attributes());

tr.render_open(&mut cursor.buffer)?;
td.render_open(&mut cursor.buffer)?;
Expand Down
14 changes: 9 additions & 5 deletions packages/mrml-core/src/mj_accordion_text/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ impl<'root> Renderer<'root, MjAccordionText, MjAccordionTextExtra<'root>> {
.maybe_add_style("padding-right", self.attribute("padding-right"))
.maybe_add_style("padding-bottom", self.attribute("padding-bottom"))
.maybe_add_style("padding-left", self.attribute("padding-left"))
.maybe_add_style("padding", self.attribute("padding"));
.maybe_add_style("padding", self.attribute("padding"))
.set_html_attributes(self.context.header.html_attributes());

td.render_open(&mut cursor.buffer)?;
for child in self.element.children.iter() {
Expand Down Expand Up @@ -71,14 +72,17 @@ impl<'root> Render<'root> for Renderer<'root, MjAccordionText, MjAccordionTextEx
let font_families = self.attribute("font-family");
cursor.header.maybe_add_font_families(font_families);

let tr = Tag::tr();
let tbody = Tag::tbody();
let tr = Tag::tr().set_html_attributes(self.context.header.html_attributes());
let tbody = Tag::tbody().set_html_attributes(self.context.header.html_attributes());
let table = Tag::table()
.add_attribute("cellspacing", "0")
.add_attribute("cellpadding", "0")
.add_style("width", "100%")
.maybe_add_style("border-bottom", self.attribute("border"));
let div = Tag::div().add_class("mj-accordion-content");
.maybe_add_style("border-bottom", self.attribute("border"))
.set_html_attributes(self.context.header.html_attributes());
let div = Tag::div()
.add_class("mj-accordion-content")
.set_html_attributes(self.context.header.html_attributes());

div.render_open(&mut cursor.buffer)?;
table.render_open(&mut cursor.buffer)?;
Expand Down
24 changes: 16 additions & 8 deletions packages/mrml-core/src/mj_accordion_title/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl<'root> Renderer<'root, MjAccordionTitle, MjAccordionTitleExtra<'root>> {
tag.add_style("display", "none")
.maybe_add_style("width", self.attribute("icon-width"))
.maybe_add_style("height", self.attribute("icon-height"))
.set_html_attributes(self.context.header.html_attributes())
}

fn render_title(&self, cursor: &mut RenderCursor) -> Result<(), Error> {
Expand All @@ -29,7 +30,8 @@ impl<'root> Renderer<'root, MjAccordionTitle, MjAccordionTitleExtra<'root>> {
.maybe_add_style("padding-bottom", self.attribute("padding-bottom"))
.maybe_add_style("padding-left", self.attribute("padding-left"))
.maybe_add_style("padding", self.attribute("padding"))
.maybe_add_class(self.attribute("css-class"));
.maybe_add_class(self.attribute("css-class"))
.set_html_attributes(self.context.header.html_attributes());

td.render_open(&mut cursor.buffer)?;
for child in self.element.children.iter() {
Expand All @@ -46,17 +48,20 @@ impl<'root> Renderer<'root, MjAccordionTitle, MjAccordionTitleExtra<'root>> {
.set_style_img(Tag::new("img"))
.maybe_add_attribute("src", self.attribute("icon-wrapped-url"))
.maybe_add_attribute("alt", self.attribute("icon-wrapped-alt"))
.add_class("mj-accordion-more");
.add_class("mj-accordion-more")
.set_html_attributes(self.context.header.html_attributes());
let img_less = self
.set_style_img(Tag::new("img"))
.maybe_add_attribute("src", self.attribute("icon-unwrapped-url"))
.maybe_add_attribute("alt", self.attribute("icon-unwrapped-alt"))
.add_class("mj-accordion-less");
.add_class("mj-accordion-less")
.set_html_attributes(self.context.header.html_attributes());
let td = Tag::td()
.add_style("padding", "16px")
.maybe_add_style("background", self.attribute("background-color"))
.maybe_add_style("vertical-align", self.attribute("icon-align"))
.add_class("mj-accordion-ico");
.add_class("mj-accordion-ico")
.set_html_attributes(self.context.header.html_attributes());

buf.start_negation_conditional_tag();
td.render_open(buf)?;
Expand Down Expand Up @@ -105,14 +110,17 @@ impl<'root> Render<'root> for Renderer<'root, MjAccordionTitle, MjAccordionTitle
let font_families = self.attribute("font-family");
cursor.header.maybe_add_font_families(font_families);

let tr = Tag::tr();
let tbody = Tag::tbody();
let tr = Tag::tr().set_html_attributes(self.context.header.html_attributes());
let tbody = Tag::tbody().set_html_attributes(self.context.header.html_attributes());
let table = Tag::table()
.add_attribute("cellspacing", "0")
.add_attribute("cellpadding", "0")
.add_style("width", "100%")
.maybe_add_style("border-bottom", self.attribute("border"));
let div = Tag::div().add_class("mj-accordion-title");
.maybe_add_style("border-bottom", self.attribute("border"))
.set_html_attributes(self.context.header.html_attributes());
let div = Tag::div()
.add_class("mj-accordion-title")
.set_html_attributes(self.context.header.html_attributes());

div.render_open(&mut cursor.buffer)?;
table.render_open(&mut cursor.buffer)?;
Expand Down
12 changes: 10 additions & 2 deletions packages/mrml-core/src/mj_body/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ impl<'root> Renderer<'root, MjBody, ()> {
}

fn get_body_tag(&self) -> Tag {
self.set_body_style(Tag::new("body").add_style("word-spacing", "normal"))
self.set_body_style(
Tag::new("body")
.add_style("word-spacing", "normal")
.set_html_attributes(self.context.header.html_attributes()),
)
}

fn get_content_div_tag(&self) -> Tag {
self.set_body_style(Tag::new("div"))
.maybe_add_attribute("class", self.attribute("css-class"))
.maybe_add_attribute("lang", self.context.header.lang())
.set_html_attributes(self.context.header.html_attributes())
}

fn set_body_style<'a, 't>(&'a self, tag: Tag<'t>) -> Tag<'t>
Expand All @@ -26,6 +31,7 @@ impl<'root> Renderer<'root, MjBody, ()> {
'a: 't,
{
tag.maybe_add_style("background-color", self.attribute("background-color"))
.set_html_attributes(self.context.header.html_attributes())
}

fn render_preview(&self, buf: &mut RenderBuffer) {
Expand Down Expand Up @@ -80,7 +86,9 @@ impl<'root> Render<'root> for Renderer<'root, MjBody, ()> {
}

fn render(&self, cursor: &mut RenderCursor) -> Result<(), Error> {
let body = self.get_body_tag();
let body = self
.get_body_tag()
.set_html_attributes(self.context.header.html_attributes());
body.render_open(&mut cursor.buffer)?;
self.render_preview(&mut cursor.buffer);
self.render_content(cursor)?;
Expand Down
14 changes: 9 additions & 5 deletions packages/mrml-core/src/mj_button/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,18 @@ impl<'root> Render<'root> for Renderer<'root, MjButton, ()> {
let font_family = self.attribute("font-family");
cursor.header.maybe_add_font_families(font_family);

let table = self.set_style_table(Tag::table_presentation());
let tbody = Tag::tbody();
let tr = Tag::tr();
let table = self
.set_style_table(Tag::table_presentation())
.set_html_attributes(self.context.header.html_attributes());
let tbody = Tag::tbody().set_html_attributes(self.context.header.html_attributes());
let tr = Tag::tr().set_html_attributes(self.context.header.html_attributes());
let td = self
.set_style_td(Tag::td())
.add_attribute("align", "center")
.maybe_add_attribute("bgcolor", self.attribute("background-color"))
.add_attribute("role", "presentation")
.maybe_add_attribute("valign", self.attribute("vertical-align"));
.maybe_add_attribute("valign", self.attribute("vertical-align"))
.set_html_attributes(self.context.header.html_attributes());
let link = Tag::new(self.attribute("href").map(|_| "a").unwrap_or("p"))
.maybe_add_attribute("href", self.attribute("href"))
.maybe_add_attribute("rel", self.attribute("rel"))
Expand All @@ -147,7 +150,8 @@ impl<'root> Render<'root> for Renderer<'root, MjButton, ()> {
"target",
self.attribute("href")
.and_then(|_v| self.attribute("target")),
);
)
.set_html_attributes(self.context.header.html_attributes());
let link = self.set_style_content(link);

table.render_open(&mut cursor.buffer)?;
Expand Down
34 changes: 23 additions & 11 deletions packages/mrml-core/src/mj_carousel/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ impl<'root> Renderer<'root, MjCarousel, MjCarouselExtra> {
.map(|value| value.value());
let div = self
.set_style_controls_div(Tag::div())
.add_class(format!("mj-carousel-{direction}-icons"));
.add_class(format!("mj-carousel-{direction}-icons"))
.set_html_attributes(self.context.header.html_attributes());
let td = self
.set_style_controls_td(Tag::td())
.add_class(format!("mj-carousel-{}-icons-cell", self.extra.id));
.add_class(format!("mj-carousel-{}-icons-cell", self.extra.id))
.set_html_attributes(self.context.header.html_attributes());

td.render_open(buf)?;
div.render_open(buf)?;
Expand All @@ -158,14 +160,16 @@ impl<'root> Renderer<'root, MjCarousel, MjCarouselExtra> {
.set_style_controls_img(Tag::new("img"))
.add_attribute("src", icon.to_string())
.add_attribute("alt", direction.to_string())
.maybe_add_attribute("width", icon_width.map(|v| v.to_string()));
.maybe_add_attribute("width", icon_width.map(|v| v.to_string()))
.set_html_attributes(self.context.header.html_attributes());
let label = Tag::new("label")
.add_attribute(
"for",
format!("mj-carousel-{}-radio-{}", self.extra.id, index + 1),
)
.add_class(format!("mj-carousel-{direction}"))
.add_class(format!("mj-carousel-{}-{}", direction, index + 1));
.add_class(format!("mj-carousel-{}-{}", direction, index + 1))
.set_html_attributes(self.context.header.html_attributes());
label.render_open(buf)?;
img.render_closed(buf)?;
label.render_close(buf);
Expand All @@ -177,8 +181,12 @@ impl<'root> Renderer<'root, MjCarousel, MjCarouselExtra> {
}

fn render_images(&self, cursor: &mut RenderCursor) -> Result<(), Error> {
let div = Tag::div().add_class("mj-carousel-images");
let td = self.set_style_images_td(Tag::td());
let div = Tag::div()
.add_class("mj-carousel-images")
.set_html_attributes(self.context.header.html_attributes());
let td = self
.set_style_images_td(Tag::td())
.set_html_attributes(self.context.header.html_attributes());

td.render_open(&mut cursor.buffer)?;
div.render_open(&mut cursor.buffer)?;
Expand All @@ -202,12 +210,13 @@ impl<'root> Renderer<'root, MjCarousel, MjCarouselExtra> {
}

fn render_carousel(&self, cursor: &mut RenderCursor) -> Result<(), Error> {
let tr = Tag::tr();
let tbody = Tag::tbody();
let tr = Tag::tr().set_html_attributes(self.context.header.html_attributes());
let tbody = Tag::tbody().set_html_attributes(self.context.header.html_attributes());
let table = self
.set_style_carousel_table(Tag::table_presentation())
.add_attribute("width", "100%")
.add_class("mj-carousel-main");
.add_class("mj-carousel-main")
.set_html_attributes(self.context.header.html_attributes());

table.render_open(&mut cursor.buffer)?;
tbody.render_open(&mut cursor.buffer)?;
Expand Down Expand Up @@ -468,8 +477,11 @@ impl<'root> Render<'root> for Renderer<'root, MjCarousel, MjCarouselExtra> {
let inner_div = self
.set_style_carousel_div(Tag::div())
.add_class("mj-carousel-content")
.add_class(format!("mj-carousel-{}-content", self.extra.id));
let div = Tag::div().add_class("mj-carousel");
.add_class(format!("mj-carousel-{}-content", self.extra.id))
.set_html_attributes(self.context.header.html_attributes());
let div = Tag::div()
.add_class("mj-carousel")
.set_html_attributes(self.context.header.html_attributes());

cursor.buffer.start_mso_negation_conditional_tag();
div.render_open(&mut cursor.buffer)?;
Expand Down
32 changes: 20 additions & 12 deletions packages/mrml-core/src/mj_carousel_image/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl<'root> Renderer<'root, MjCarouselImage, MjCarouselImageExtra<'root>> {
.get("carousel-id")
.map(|id| format!("mj-carousel-{}-radio-{}", id, self.index + 1)),
)
.set_html_attributes(self.context.header.html_attributes())
.render_closed(buf)
.map_err(Error::from)
}
Expand All @@ -102,14 +103,17 @@ impl<'root> Renderer<'root, MjCarouselImage, MjCarouselImageExtra<'root>> {
self.container_width
.as_ref()
.map(|item| item.value().to_string()),
);
let label = Tag::new("label").maybe_add_attribute(
"for",
self.extra
.attributes
.get("carousel-id")
.map(|id| format!("mj-carousel-{}-radio-{}", id, self.index + 1)),
);
)
.set_html_attributes(self.context.header.html_attributes());
let label = Tag::new("label")
.maybe_add_attribute(
"for",
self.extra
.attributes
.get("carousel-id")
.map(|id| format!("mj-carousel-{}-radio-{}", id, self.index + 1)),
)
.set_html_attributes(self.context.header.html_attributes());
let link = self
.set_style_thumbnails_a(Tag::new("a"))
.add_attribute("href", format!("#{}", self.index + 1))
Expand All @@ -131,7 +135,8 @@ impl<'root> Renderer<'root, MjCarouselImage, MjCarouselImageExtra<'root>> {
.maybe_add_style(
"width",
self.container_width.as_ref().map(|item| item.to_string()),
);
)
.set_html_attributes(self.context.header.html_attributes());

link.render_open(buf)?;
label.render_open(buf)?;
Expand Down Expand Up @@ -206,7 +211,8 @@ impl<'root> Render<'root> for Renderer<'root, MjCarouselImage, MjCarouselImageEx
self.container_width
.as_ref()
.map(|width| width.value().to_string()),
);
)
.set_html_attributes(self.context.header.html_attributes());
let div = if self.index == 0 {
Tag::div()
} else {
Expand All @@ -217,14 +223,16 @@ impl<'root> Render<'root> for Renderer<'root, MjCarouselImage, MjCarouselImageEx
let div = div
.add_class("mj-carousel-image")
.add_class(format!("mj-carousel-image-{}", self.index + 1))
.maybe_add_class(self.attribute("css-class"));
.maybe_add_class(self.attribute("css-class"))
.set_html_attributes(self.context.header.html_attributes());

div.render_open(&mut cursor.buffer)?;
if let Some(href) = self.attribute("href") {
let link = Tag::new("a")
.add_attribute("href", href)
.maybe_add_attribute("rel", self.attribute("rel"))
.add_attribute("target", "_blank");
.add_attribute("target", "_blank")
.set_html_attributes(self.context.header.html_attributes());
link.render_open(&mut cursor.buffer)?;
img.render_closed(&mut cursor.buffer)?;
link.render_close(&mut cursor.buffer);
Expand Down
Loading
Loading