[][src]Trait funcy::PlaceholderFunction

pub trait PlaceholderFunction {
    pub fn placeholder_fn_handler<'a>(
        &mut self,
        name: &'a str,
        arg: &'a str
    ) -> Result<String, String>; }

Trait used to define functions that can be called from placeholders.

Example

struct Echo();
impl funcy::PlaceholderFunction for Echo {
    fn placeholder_fn_handler<'a>(&mut self, _name: &'a str, arg: &'a str) -> Result<String, String> {
        Ok(arg.to_string())
    }
}

Required methods

pub fn placeholder_fn_handler<'a>(
    &mut self,
    name: &'a str,
    arg: &'a str
) -> Result<String, String>
[src]

Called when a placeholder references the function. The arg may be empty. Errors returned will be propagated and returned from the TemplateRenderer::render function.

The name argument includes the name of the placeholder function being called. This can be used to have one struct handle multiple placeholder functions.

Loading content...

Implementors

Loading content...