1.0.3 • Published 6 years ago

substitute.js v1.0.3

Weekly downloads
18
License
-
Repository
github
Last release
6 years ago

substitute.js

A javascript micro template, reference Dojo

Usage

Basic

    import substitute from 'substitute.js';

    const template = "<div>${name}</div><div>${age}</div>";

    const map = {
        name : "Linus Wang",
        age: 23
    };

    const string = substitute(template, map);

Use format

    const template = "${name:nameFmt} ${age:ageFmt}";

    const map = {
        name : "Linus Wang"
    };

    const thisObject = {
        nameFmt : function(value, key){
            return key + " is: " + value;
        }, 
        ageFmt : function(value, key){
            return key + " is: " + value;
        },
        transform : function(value, key){
            return value;
        }
    }

    const string = substitute(template, map, null, thisObject);
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.1

7 years ago

0.1.0

7 years ago