-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstring-templater.js
60 lines (48 loc) · 1.3 KB
/
string-templater.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
let StringTemplater = (function(){
const defaults = {
withValues : null,
withTemplate : null,
tagsStartWith : "",
tagsEndWith : ""
};
function create(options){
var stringTemplater = {};
stringTemplater.options = Object.assign({}, defaults, options);
bind(stringTemplater);
return stringTemplater;
}
function bind(stringTemplater){
stringTemplater.withValues = withValues.bind(stringTemplater);
stringTemplater.withTemplate = withTemplate.bind(stringTemplater);
stringTemplater.tagsStartWith = tagsStartWith.bind(stringTemplater);
stringTemplater.tagsEndWith = tagsEndWith.bind(stringTemplater);
stringTemplater.template = template.bind(stringTemplater);
}
function withValues(values){
this.options.withValues = values;
return this;
}
function withTemplate(values){
this.options.withValues = values;
return this;
}
function tagsStartWith(value){
this.options.tagsStartWith = value;
return this;
}
function tagsEndWith(value){
this.options.tagsEndWith = value;
return this;
}
function template(text, values){
if(!text){
text = this.options.withTemplate;
}
if(!values){
values = this.options.withValues;
}
}
return {
create : create
};
})();