string-interpolate

2019-05-17 admin

string-interpolate是什么

什么是string-interpolate,Simple string interpolation

string-interpolate使用教程帮助文档

String interpolate

Simple string interpolation

Install

$ npm install string-interpolate
$ component install alexeyraspopov/string-interpolate
$ bower install string-interpolate

API

interpolate(template, data);

  • template - template string. Default delimiters are {}
  • data - simple object

Usage

var interpolate = require('string-interpolate');

interpolate('{ greeting }, { user.name }', {
	greeting: 'Hello',
	user: {
		name: 'Jane'
	}
});

If data is not specified - returns template function

var greet = interpolate('Hello { name }');

greet({ name: 'Jane' }); // Hello Jane
greet({ name: 'Mike' }); // Hello Mike

License

MIT License © Alexey Raspopov

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-65147.html

文章标题:string-interpolate

回到顶部