[−][src]Struct bempline::Document
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]
&mut self,
name: &str,
pattern: Document
) -> Result<usize, Error>
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
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,