Struct build_html::TableCell

source ·
pub struct TableCell { /* private fields */ }
Expand description

A single table cell

TableCell implements HtmlContainer, so it can be filled just like any other Container.

Example

let cell = TableCell::new(TableCellType::Header)
    .with_attributes([("id", "header-cell"), ("class", "headers")])
    .with_paragraph("Here's a paragraph!")
    .to_html_string();

assert_eq!(cell, r#"<th id="header-cell" class="headers"><p>Here's a paragraph!</p></th>"#);

Implementations§

source§

impl TableCell

source

pub fn new(cell_type: TableCellType) -> Self

Create a new TableCell with the given type

source

pub fn with_attributes<A, S>(self, attributes: A) -> Selfwhere A: IntoIterator<Item = (S, S)>, S: ToString,

Set the attributes for this row.

Note that this operation overrides all previous invocations of with_attributes.

Example
let out = TableCell::default()
    .with_attributes([("id", "first-cell")])
    .with_paragraph("Hello, World!")
    .to_html_string();
assert_eq!(out, r#"<td id="first-cell"><p>Hello, World!</p></td>"#)

Trait Implementations§

source§

impl Debug for TableCell

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TableCell

source§

fn default() -> TableCell

Returns the “default value” for a type. Read more
source§

impl Html for TableCell

source§

fn to_html_string(&self) -> String

Convert this element into an HTML string Read more
source§

impl HtmlContainer for TableCell

source§

fn add_html<H: Html>(&mut self, html: H)

Adds the specified HTML element to this container Read more
source§

fn with_html<H: Html>(self, html: H) -> Self

Consumes the container, returning it with the specified HTML element added to it Read more
source§

fn add_container(&mut self, container: Container)

Add the container to this HTML Container Read more
source§

fn with_container(self, container: Container) -> Self

Nest the specified container within this container Read more
source§

fn add_table(&mut self, table: Table)

Add the specified Table to this container Read more
source§

fn with_table(self, table: Table) -> Self

Nest the specified Table within this container Read more
source§

fn add_header(&mut self, level: u8, text: impl ToString)

Adds a header tag with the designated level to this container Read more
source§

fn with_header(self, level: u8, text: impl ToString) -> Self

Adds a header tag with the designated level to this container Read more
source§

fn add_header_attr<A, S>(&mut self, level: u8, text: impl ToString, attr: A)where A: IntoIterator<Item = (S, S)>, S: ToString,

Adds a header tag with the designated level and attributes to this container. Read more
source§

fn with_header_attr<A, S>(self, level: u8, text: impl ToString, attr: A) -> Selfwhere A: IntoIterator<Item = (S, S)>, S: ToString,

Adds a header tag with the designated level and attributes to this container. Read more
source§

fn add_image(&mut self, src: impl ToString, alt: impl ToString)

Adds an <img> tag to this container Read more
source§

fn with_image(self, src: impl ToString, alt: impl ToString) -> Self

Adds an <img> tag to this container Read more
source§

fn add_image_attr<A, S>( &mut self, src: impl ToString, alt: impl ToString, attr: A )where A: IntoIterator<Item = (S, S)>, S: ToString,

Adds an <img> tag with the specified attributes to this container Read more
source§

fn with_image_attr<A, S>( self, src: impl ToString, alt: impl ToString, attr: A ) -> Selfwhere A: IntoIterator<Item = (S, S)>, S: ToString,

Adds an <img> tag with the specified attributes to this container Read more
Adds an <a> tag to this container Read more
Adds an <a> tag to this container Read more
Adds an <a> tag with the specified attributes to this container Read more
Adds an <a> tag with the specified attributes to this container Read more
source§

fn add_paragraph(&mut self, text: impl ToString)

Adds a <p> tag element to this Container Read more
source§

fn with_paragraph(self, text: impl ToString) -> Self

Adds a <p> tag element to this Container Read more
source§

fn add_paragraph_attr<A, S>(&mut self, text: impl ToString, attr: A)where A: IntoIterator<Item = (S, S)>, S: ToString,

Adds a <p> tag element with the specified attributes to this Container Read more
source§

fn with_paragraph_attr<A, S>(self, text: impl ToString, attr: A) -> Selfwhere A: IntoIterator<Item = (S, S)>, S: ToString,

Adds a <p> tag element with the specified attributes to this Container Read more
source§

fn add_preformatted(&mut self, text: impl ToString)

Adds a <pre> tag element to this container Read more
source§

fn with_preformatted(self, text: impl ToString) -> Self

Adds a <pre> tag element to this container Read more
source§

fn add_preformatted_attr<A, S>(&mut self, text: impl ToString, attr: A)where A: IntoIterator<Item = (S, S)>, S: ToString,

Adds a <pre> tag element with the specified attributes to this container Read more
source§

fn with_preformatted_attr<A, S>(self, text: impl ToString, attr: A) -> Selfwhere A: IntoIterator<Item = (S, S)>, S: ToString,

Adds a <pre> tag element with the specified attributes to this container Read more
source§

fn add_raw(&mut self, content: impl ToString)

Add raw content to the container. This content is pasted directly into the HTML Read more
source§

fn with_raw(self, content: impl ToString) -> Self

Add raw content to this container. The content is pasted directly into the HTML Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.