Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yosuke-furukawa/string_tmpl.jsx
Super Easy String template
https://github.com/yosuke-furukawa/string_tmpl.jsx
Last synced: about 1 month ago
JSON representation
Super Easy String template
- Host: GitHub
- URL: https://github.com/yosuke-furukawa/string_tmpl.jsx
- Owner: yosuke-furukawa
- Created: 2014-03-18T09:17:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T14:43:11.000Z (11 months ago)
- Last Synced: 2024-09-17T06:56:30.869Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Super Simple String Template
=============================[![Build Status](https://travis-ci.org/yosuke-furukawa/string_tmpl.jsx.png?branch=master)](https://travis-ci.org/yosuke-furukawa/string_tmpl.jsx)
[![browser support](https://ci.testling.com/yosuke-furukawa/string_tmpl.jsx.png)
](https://ci.testling.com/yosuke-furukawa/string_tmpl.jsx)Getting Started
=================Server:
```shell
$ npm install string_tmpl
```Client:
```shell
$ bower install string_tmpl
```For javascript user
```javascript
var Template = require("string_tmpl").Template;
var test = Template.format("{test} yosuke", { test: "Hello"});
console.log(test); // Hello yosuke
```For jsx user
```javascript
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}");
}
}```