[][src]Struct bempline::Document

pub struct Document { /* fields omitted */ }

Methods

impl Document[src]

pub fn new(text: &str) -> Self[src]

pub fn set_variable(&mut self, key: &str, value: &str) -> usize[src]

Returns a usize indicating how many variables were replaced

Replace every instance of variable key with text value

Example

use bempline::Document;

let mut doc = Document::new("Hello, {~ $noun ~}!");
let num_replaced = doc.set_variable("noun", "World");

assert_eq!(num_replaced, 1);
assert_eq!(doc.as_string(), "Hello, World!");

pub fn process_includes(&mut self) -> Result<usize, Error>[src]

Returns a usize indicating the number of includes that were processed successfully.

Replaces every include command in the document with the content of the file it references.

Errors

Returns a Error if a file referenced by one of the include statements is unable to be opened for reading.

pub fn get_pattern(&self, name: &str) -> Result<Document, Error>[src]

Returns a Document of the elements in the pattern

Retreives the pattern name

Errors

Returns a Error if the pattern does not exist.

pub fn set_pattern(
    &mut self,
    name: &str,
    pattern: Document
) -> Result<usize, Error>
[src]

Returns a usize indicating how many elements were inserted into the document.

Inserts the elementa from pattern into this document, before the pattern name

Errors

Returns a Error if the pattern does not exist.

pub fn as_string(self) -> String[src]

Returns a string of this document.

Only text is included in the string. No variables, unproccesed includes, or patterns will be in the string.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.