[][src]Trait asciii::templater::IsKeyword

pub trait IsKeyword {
    fn is_keyword(&self) -> bool;
fn get_keyword(&self) -> Option<String>;
fn list_keywords(&self) -> Vec<String>;
fn map_keywords<F>(&self, closure: F) -> String
    where
        F: Fn(&str) -> String
; }

Simple template style keyword replacement.

This allows replacing a known set of keywords looking like ##THIS##. Here it is implemented for Deref<Target=str>.

Required Methods

Checks if the whole string is a keyword

Captures keywords from string.

Well, it lists the keywords in a string, duh!

This one is usefull.

Takes a clorsure that replaces keywords. Careful, this replaces either way! If you get a keywords you don't want to replace, please place it back where you got it from.

Example

This example is not tested
.map_keywords|keyword| match data.get(keyword){
    Some(content) => String::from(*content),
    None => format!("##{}##", keyword)
}

Implementors

impl<U: Deref<Target = str>> IsKeyword for U
[src]

Allows very simplistic ##KEYWORD## replacement.

Checks if the whole string is a keyword

Captures keywords from string.

Well, it lists the keywords in a string, duh!

This one is usefull.

Takes a clorsure that replaces keywords. Careful, this replaces either way! If you get a keywords you don't want to replace, please place it back where you got it from.

Example

This example is not tested
.map_keywords|keyword| match data.get(keyword){
    Some(content) => String::from(*content),
    None => format!("##{}##", keyword)
}