0.1.1 • Published 10 years ago

string_tmpl v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Super Simple String Template

Build Status

browser support

Getting Started

Server:

$ npm install string_tmpl

Client:

$ bower install string_tmpl

For javascript user

    var Template = require("string_tmpl").Template;
    var test = Template.format("{test} yosuke", { test: "Hello"});
    console.log(test); // Hello yosuke

For jsx user

import "test-case.jsx";
import "string_tmpl/string_tmpl.jsx";

class _Test extends TestCase {
    function testFormat() :void {
        var result = Template.format("{test1} = {test2}", {"test1" : "abc", "test2" : 123});
        this.expect(result).toBe("abc = 123");
        result = Template.format("{test1} = {test2} = {test3}", {"test1" : "abc", "test2" : 123});
        this.expect(result).toBe("abc = 123 = {test3}");
        result = Template.format("{test1} = {test2} = {test2}", {"test1" : "abc", "test2" : 123});
        this.expect(result).toBe("abc = 123 = 123");
    }
    function testEmptyFormat() :void {
        var result = Template.format("{test1} = {test2}", {});
        this.expect(result).toBe("{test1} = {test2}");
    }
}