From 1cef786d0c96c161747fac859df62f50f9856b2e Mon Sep 17 00:00:00 2001 From: Christian Fei Date: Mon, 10 Aug 2015 22:19:05 +0200 Subject: [PATCH] renamed Templater.compile --- src/Templater.js | 4 ++-- src/Templater.test.js | 8 ++++---- src/index.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Templater.js b/src/Templater.js index 6a13523..5abd14b 100644 --- a/src/Templater.js +++ b/src/Templater.js @@ -1,5 +1,5 @@ module.exports = { - render: render, + compile: compile, setOptions: setOptions } @@ -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 }) diff --git a/src/Templater.test.js b/src/Templater.test.js index 0b8e50d..53ebd9d 100644 --- a/src/Templater.test.js +++ b/src/Templater.test.js @@ -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('url',{url:'http://google.com'}) + templater.compile('url',{url:'http://google.com'}) ).toEqual( 'url' ) @@ -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 ) @@ -33,7 +33,7 @@ describe('Templater', function() { templatePattern:/\{\{(.*?)\}\}/g }) expect( - templater.render('{{foo}}',{foo:'bar'}) + templater.compile('{{foo}}',{foo:'bar'}) ).toEqual( 'bar' ) diff --git a/src/index.js b/src/index.js index 1caf78c..db39c98 100644 --- a/src/index.js +++ b/src/index.js @@ -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]) ) } }