Permalink
Browse files

Added cloning of `data` object when rendering a template.

  • Loading branch information...
1 parent a946939 commit afe4308f73a764cd71d315f1a7abe40d8f460770 Pierre Matri committed Aug 21, 2012
Showing with 8 additions and 5 deletions.
  1. +2 −1 .gitignore
  2. +3 −1 README.md
  3. +3 −3 lib/template.js
View
3 .gitignore
@@ -14,4 +14,5 @@ logs
results
node_modules
-npm-debug.log
+npm-debug.log
+test/run.html
View
4 README.md
@@ -69,7 +69,9 @@ Just include `kiwi.min.js`, and you're good to go!
Kiwi is also available as a CDN-hosted version, for free, courtesy of CDNJS / CloudFlare.
-```<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/kiwi/0.2.1/kiwi.min.js"><script>```
+```html
+<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/kiwi/0.2.1/kiwi.min.js"><script>
+```
### Client-side dependencies
View
6 lib/template.js
@@ -150,11 +150,11 @@ Template.prototype.render = function(data, callback) {
// Support callback as 1st arg
if(_.isFunction(data) && !callback){
callback = data;
- data = {};
+ data = null;
}
- // Data defaults
- if(!data) data = {};
+ // Data defaults and / or cloning
+ data = data ? _.clone(data) : data;
// Check whether we have the compiled template ready in the object or in cache
var cacheKey = 'template::' + this._cacheKey();

0 comments on commit afe4308

Please sign in to comment.