Skip to content
This repository was archived by the owner on Mar 16, 2022. It is now read-only.

Commit 1cef786

Browse files
committed
renamed Templater.compile
1 parent b991b21 commit 1cef786

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/Templater.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
render: render,
2+
compile: compile,
33
setOptions: setOptions
44
}
55

@@ -11,7 +11,7 @@ function setOptions(_opt){
1111
opt.templatePattern = _opt.templatePattern || /\{(.*?)\}/g
1212
}
1313

14-
function render(t, data){
14+
function compile(t, data){
1515
return t.replace(opt.templatePattern, function(match, prop) {
1616
return data[prop] || match
1717
})

src/Templater.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ describe('Templater', function() {
77

88
it('renders the template with the provided data', function() {
99
expect(
10-
templater.render('{foo}',{foo:'bar'})
10+
templater.compile('{foo}',{foo:'bar'})
1111
).toEqual(
1212
'bar'
1313
)
1414

1515
expect(
16-
templater.render('<a href="{url}">url</a>',{url:'http://google.com'})
16+
templater.compile('<a href="{url}">url</a>',{url:'http://google.com'})
1717
).toEqual(
1818
'<a href="http://google.com">url</a>'
1919
)
@@ -22,7 +22,7 @@ describe('Templater', function() {
2222
it('replaces not found properties with the original pattern', function() {
2323
var template = '{foo}'
2424
expect(
25-
templater.render(template,{x:'bar'})
25+
templater.compile(template,{x:'bar'})
2626
).toEqual(
2727
template
2828
)
@@ -33,7 +33,7 @@ describe('Templater', function() {
3333
templatePattern:/\{\{(.*?)\}\}/g
3434
})
3535
expect(
36-
templater.render('{{foo}}',{foo:'bar'})
36+
templater.compile('{{foo}}',{foo:'bar'})
3737
).toEqual(
3838
'bar'
3939
)

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
return appendToResultsContainer(options.noResultsText)
8787
}
8888
for (var i = 0; i < results.length; i++) {
89-
appendToResultsContainer( templater.render(options.searchResultTemplate, results[i]) )
89+
appendToResultsContainer( templater.compile(options.searchResultTemplate, results[i]) )
9090
}
9191
}
9292

0 commit comments

Comments
 (0)