Struct html_builder::Node

source ·
pub struct Node<'a> { /* private fields */ }
Expand description

An HTML element.

An open-tag is written to the buffer when a Node is created, and a close-tag is written when the Node is dropped. You can set attributes on a newly-created node using attr(), create child nodes with child(), and write text into the node using the Write impl.

Escaping

Text written into a node using its Write impl is transformed to make it render correctly in an HTML-context. By default, the following characters are escaped: &, <, and >. The escaping can be strengthened or weakened using the safe() and raw() methods respectively.

Implementations§

source§

impl<'a> Node<'a>

source

pub fn child<'b>(&'b mut self, tag: Cow<'static, str>) -> Node<'b>

source

pub fn void_child<'b>(&'b mut self, tag: Cow<'static, str>) -> Void<'b>

source

pub fn comment<'b>(&'b mut self) -> Comment<'b>

source

pub fn attr(self, attr: &str) -> Node<'a>

source

pub fn raw(self) -> Node<'a>

Disable escaping

In this mode, written text is passed through unmodified.

source

pub fn safe(self) -> Node<'a>

Escape more special characters

In this mode, the following characters are escaped: &, <, >, ", ', and /.

Trait Implementations§

source§

impl<'a> Html5 for Node<'a>

source§

fn doctype(&mut self)

Defines the document type

source§

fn a(&mut self) -> Node<'_>

Defines a hyperlink

source§

fn abbr(&mut self) -> Node<'_>

Defines an abbreviation or an acronym

source§

fn address(&mut self) -> Node<'_>

Defines contact information for the author/owner of a document

source§

fn area(&mut self) -> Void<'_>

Defines an area inside an image map

source§

fn article(&mut self) -> Node<'_>

Defines an article

source§

fn aside(&mut self) -> Node<'_>

Defines content aside from the page content

source§

fn audio(&mut self) -> Node<'_>

Defines embedded sound content

source§

fn b(&mut self) -> Node<'_>

Defines bold text

source§

fn base(&mut self) -> Void<'_>

Specifies the base URL/target for all relative URLs in a document

source§

fn bdi(&mut self) -> Node<'_>

Isolates a part of text that might be formatted in a different direction from other text outside it

source§

fn bdo(&mut self) -> Node<'_>

Overrides the current text direction

source§

fn blockquote(&mut self) -> Node<'_>

Defines a section that is quoted from another source

source§

fn body(&mut self) -> Node<'_>

Defines the document’s body

source§

fn br(&mut self) -> Void<'_>

Defines a single line break

source§

fn button(&mut self) -> Node<'_>

Defines a clickable button

source§

fn canvas(&mut self) -> Node<'_>

Used to draw graphics, on the fly, via scripting (usually JavaScript)

source§

fn caption(&mut self) -> Node<'_>

Defines a table caption

source§

fn cite(&mut self) -> Node<'_>

Defines the title of a work

source§

fn code(&mut self) -> Node<'_>

Defines a piece of computer code

source§

fn col(&mut self) -> Void<'_>

Specifies column properties for each column within a <colgroup> element

source§

fn colgroup(&mut self) -> Node<'_>

Specifies a group of one or more columns in a table for formatting

source§

fn data(&mut self) -> Node<'_>

Adds a machine-readable translation of a given content

source§

fn datalist(&mut self) -> Node<'_>

Specifies a list of pre-defined options for input controls

source§

fn dd(&mut self) -> Node<'_>

Defines a description/value of a term in a description list

source§

fn del(&mut self) -> Node<'_>

Defines text that has been deleted from a document

source§

fn details(&mut self) -> Node<'_>

Defines additional details that the user can view or hide

source§

fn dfn(&mut self) -> Node<'_>

Specifies a term that is going to be defined within the content

source§

fn dialog(&mut self) -> Node<'_>

Defines a dialog box or window

source§

fn div(&mut self) -> Node<'_>

Defines a section in a document

source§

fn dl(&mut self) -> Node<'_>

Defines a description list

source§

fn dt(&mut self) -> Node<'_>

Defines a term/name in a description list

source§

fn em(&mut self) -> Node<'_>

Defines emphasized text

source§

fn embed(&mut self) -> Void<'_>

Defines a container for an external application

source§

fn fieldset(&mut self) -> Node<'_>

Groups related elements in a form

source§

fn figcaption(&mut self) -> Node<'_>

Defines a caption for a <figure> element

source§

fn figure(&mut self) -> Node<'_>

Specifies self-contained content

source§

fn footer(&mut self) -> Node<'_>

Defines a footer for a document or section

source§

fn form(&mut self) -> Node<'_>

Defines an HTML form for user input

source§

fn h1(&mut self) -> Node<'_>

Defines HTML headings

source§

fn h2(&mut self) -> Node<'_>

Defines HTML headings

source§

fn h3(&mut self) -> Node<'_>

Defines HTML headings

source§

fn h4(&mut self) -> Node<'_>

Defines HTML headings

source§

fn h5(&mut self) -> Node<'_>

Defines HTML headings

source§

fn h6(&mut self) -> Node<'_>

Defines HTML headings

source§

fn head(&mut self) -> Node<'_>

Contains metadata/information for the document

source§

fn header(&mut self) -> Node<'_>

Defines a header for a document or section

source§

fn hr(&mut self) -> Void<'_>

Defines a thematic change in the content

source§

fn html(&mut self) -> Node<'_>

Defines the root of an HTML document

source§

fn i(&mut self) -> Node<'_>

Defines a part of text in an alternate voice or mood

source§

fn iframe(&mut self) -> Node<'_>

Defines an inline frame

source§

fn img(&mut self) -> Void<'_>

Defines an image

source§

fn input(&mut self) -> Void<'_>

Defines an input control

source§

fn ins(&mut self) -> Node<'_>

Defines a text that has been inserted into a document

source§

fn kbd(&mut self) -> Node<'_>

Defines keyboard input

source§

fn label(&mut self) -> Node<'_>

Defines a label for an <input> element

source§

fn legend(&mut self) -> Node<'_>

Defines a caption for a <fieldset> element

source§

fn li(&mut self) -> Node<'_>

Defines a list item

Defines the relationship between a document and an external resource (most used to link to style sheets)

source§

fn main(&mut self) -> Node<'_>

Specifies the main content of a document

source§

fn map(&mut self) -> Node<'_>

Defines an image map

source§

fn mark(&mut self) -> Node<'_>

Defines marked/highlighted text

source§

fn meta(&mut self) -> Void<'_>

Defines metadata about an HTML document

source§

fn meter(&mut self) -> Node<'_>

Defines a scalar measurement within a known range (a gauge)

source§

fn nav(&mut self) -> Node<'_>

Defines navigation links

source§

fn noscript(&mut self) -> Node<'_>

Defines an alternate content for users that do not support client-side scripts

source§

fn object(&mut self) -> Node<'_>

Defines a container for an external application

source§

fn ol(&mut self) -> Node<'_>

Defines an ordered list

source§

fn optgroup(&mut self) -> Node<'_>

Defines a group of related options in a drop-down list

source§

fn option(&mut self) -> Node<'_>

Defines an option in a drop-down list

source§

fn output(&mut self) -> Node<'_>

Defines the result of a calculation

source§

fn p(&mut self) -> Node<'_>

Defines a paragraph

source§

fn param(&mut self) -> Void<'_>

Defines a parameter for an object

source§

fn picture(&mut self) -> Node<'_>

Defines a container for multiple image resources

source§

fn pre(&mut self) -> Node<'_>

Defines preformatted text

source§

fn progress(&mut self) -> Node<'_>

Represents the progress of a task

source§

fn q(&mut self) -> Node<'_>

Defines a short quotation

source§

fn rp(&mut self) -> Node<'_>

Defines what to show in browsers that do not support ruby annotations

source§

fn rt(&mut self) -> Node<'_>

Defines an explanation/pronunciation of characters (for East Asian typography)

source§

fn ruby(&mut self) -> Node<'_>

Defines a ruby annotation (for East Asian typography)

source§

fn s(&mut self) -> Node<'_>

Defines text that is no longer correct

source§

fn samp(&mut self) -> Node<'_>

Defines sample output from a computer program

source§

fn script(&mut self) -> Node<'_>

Defines a client-side script

source§

fn section(&mut self) -> Node<'_>

Defines a section in a document

source§

fn select(&mut self) -> Node<'_>

Defines a drop-down list

source§

fn small(&mut self) -> Node<'_>

Defines smaller text

source§

fn source(&mut self) -> Void<'_>

Defines multiple media resources for media elements (<video> and <audio>)

source§

fn span(&mut self) -> Node<'_>

Defines a section in a document

source§

fn strong(&mut self) -> Node<'_>

Defines important text

source§

fn style(&mut self) -> Node<'_>

Defines style information for a document

source§

fn sub(&mut self) -> Node<'_>

Defines subscripted text

source§

fn summary(&mut self) -> Node<'_>

Defines a visible heading for a <details> element

source§

fn sup(&mut self) -> Node<'_>

Defines superscripted text

source§

fn svg(&mut self) -> Node<'_>

Defines a container for SVG graphics

source§

fn table(&mut self) -> Node<'_>

Defines a table

source§

fn tbody(&mut self) -> Node<'_>

Groups the body content in a table

source§

fn td(&mut self) -> Node<'_>

Defines a cell in a table

source§

fn template(&mut self) -> Node<'_>

Defines a container for content that should be hidden when the page loads

source§

fn textarea(&mut self) -> Node<'_>

Defines a multiline input control (text area)

source§

fn tfoot(&mut self) -> Node<'_>

Groups the footer content in a table

source§

fn th(&mut self) -> Node<'_>

Defines a header cell in a table

source§

fn thead(&mut self) -> Node<'_>

Groups the header content in a table

source§

fn time(&mut self) -> Node<'_>

Defines a specific time (or datetime)

source§

fn title(&mut self) -> Node<'_>

Defines a title for the document

source§

fn tr(&mut self) -> Node<'_>

Defines a row in a table

source§

fn track(&mut self) -> Void<'_>

Defines text tracks for media elements (<video> and <audio>)

source§

fn u(&mut self) -> Node<'_>

Defines some text that is unarticulated and styled differently from normal text

source§

fn ul(&mut self) -> Node<'_>

Defines an unordered list

source§

fn var(&mut self) -> Node<'_>

Defines a variable

source§

fn video(&mut self) -> Node<'_>

Defines embedded video content

source§

fn wbr(&mut self) -> Void<'_>

Defines a possible line-break

source§

impl<'a> Write for Node<'a>

source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Node<'a>

§

impl<'a> Send for Node<'a>

§

impl<'a> Sync for Node<'a>

§

impl<'a> Unpin for Node<'a>

§

impl<'a> UnwindSafe for Node<'a>

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.