femstache 0.1.2

Embrace the feminine mustache to unlock your templating dreams! Or something, I don't know. :3
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::{borrow::Borrow, collections::BTreeMap};

use crate::value::{ToValue, Value};

/// Trait used to get strings to interpolate into the templates
pub trait TemplateInput {
    /// Get the item with key `key`, return `Some` when it exists and `None`
    /// when it does not
    fn get(&self, key: &str) -> Option<Value>;
}

impl<K: Borrow<str> + Ord, V: ToValue> TemplateInput for BTreeMap<K, V> {
    fn get(&self, key: &str) -> Option<Value> {
        self.get(key).map(|v| v.to_value())
    }
}