Skip to content

yosuke-furukawa/string_tmpl.jsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Super Easy String template

Resources

Stars

Watchers

Forks

Packages

No packages published