-
Couldn't load subscription status.
- Fork 0
ProtoString template() Method
Seth Clydesdale edited this page Jun 3, 2015
·
2 revisions
The string variable name should be the same as the object key.
'Hello ${name}, would you like some ${food}?'.template({
name : 'Seth',
food : 'coffee'
});
// returns 'Hello Seth, would you like some coffee?'The template method aims to give you similar functionality to the template strings in ES6. Inline string variables are defined using ${VAR}, where VAR is the name of your variable. An object passed as the parameter defines all the variable data.
String.template(data);| Parameter | Description |
|---|---|
| data | An Object which contains the variable data for the string. Object keys should be spelt the same as your string variables. |
Home • History • ProtoString • Created by Seth Clydesdale