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

Commit

Permalink
renamed Templater.compile
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-fei committed Aug 10, 2015
1 parent b991b21 commit 1cef786
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Templater.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
render: render,
compile: compile,
setOptions: setOptions
}

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

function render(t, data){
function compile(t, data){
return t.replace(opt.templatePattern, function(match, prop) {
return data[prop] || match
})
Expand Down
8 changes: 4 additions & 4 deletions src/Templater.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ describe('Templater', function() {

it('renders the template with the provided data', function() {
expect(
templater.render('{foo}',{foo:'bar'})
templater.compile('{foo}',{foo:'bar'})
).toEqual(
'bar'
)

expect(
templater.render('<a href="{url}">url</a>',{url:'http://google.com'})
templater.compile('<a href="{url}">url</a>',{url:'http://google.com'})
).toEqual(
'<a href="http://google.com">url</a>'
)
Expand All @@ -22,7 +22,7 @@ describe('Templater', function() {
it('replaces not found properties with the original pattern', function() {
var template = '{foo}'
expect(
templater.render(template,{x:'bar'})
templater.compile(template,{x:'bar'})
).toEqual(
template
)
Expand All @@ -33,7 +33,7 @@ describe('Templater', function() {
templatePattern:/\{\{(.*?)\}\}/g
})
expect(
templater.render('{{foo}}',{foo:'bar'})
templater.compile('{{foo}}',{foo:'bar'})
).toEqual(
'bar'
)
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
return appendToResultsContainer(options.noResultsText)
}
for (var i = 0; i < results.length; i++) {
appendToResultsContainer( templater.render(options.searchResultTemplate, results[i]) )
appendToResultsContainer( templater.compile(options.searchResultTemplate, results[i]) )
}
}

Expand Down

0 comments on commit 1cef786

Please sign in to comment.