Trait ructe::templates::ToHtml [−][src]
pub trait ToHtml { fn to_html(&self, out: &mut dyn Write) -> Result<()>; fn to_buffer(&self) -> Result<HtmlBuffer> { ... } }
Expand description
This trait should be implemented for any value that can be the result of an expression in a template.
This trait decides how to format the given object as html.
There exists a default implementation for any T: Display
that
formats the value using Display and then html-encodes the result.
Required methods
Provided methods
fn to_buffer(&self) -> Result<HtmlBuffer>
fn to_buffer(&self) -> Result<HtmlBuffer>
Write the HTML represention of this value to a buffer.
This can be used for testing, and for short-cutting situations with complex ownership, since the resulting buffer gets owned by the caller.
Examples
use templates::ToHtml; assert_eq!(17.to_buffer()?, "17"); assert_eq!("a < b".to_buffer()?, "a < b");