string_tmpl

0.1.1 • Public • Published

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}");
    }
}
 

Readme

Keywords

Package Sidebar

Install

npm i string_tmpl

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • yosuke-furukawa