Skip to content

woodgear/simple-replace-templete-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

feature

Give the variables you want to have when rendering

how to use

    
    fn test_get_variable() {
        use crate::get_variables;
        let vars = get_variables("hello _t_name_t_", "_t_");
        assert_eq!(vars, vec!["name".to_owned()]);
    }

    fn test_replace() {
        use crate::render;
        use std::collections::HashMap;

        let map = {
            let mut map = HashMap::new();
            map.insert("name".to_owned(), "me".to_owned());
            map
        };
        let templete_str = "hello _t_name_t_".to_owned();

        let ret = render(&templete_str, "_t_", &map).unwrap();
        assert_eq!(ret, "hello me".to_owned());
    }

About

a simple search and replace templete engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages