Permalink
Browse files

Passes jslint validation and displays an empty string for null or und…

…efined values.
  • Loading branch information...
1 parent b83591b commit 72098e95cf6ef57641ff1dd238157ff6c39914fa Caleb Wright committed Mar 19, 2010
Showing with 8 additions and 8 deletions.
  1. +8 −8 jquery.nano.js
View
16 jquery.nano.js
@@ -1,11 +1,11 @@
/* Nano Templates (Tomasz Mazur, Jacek Becela) */
(function($){
- $.nano = function(template, data){
- return template.replace(/\{([\w\.]*)}/g, function(str, key){
- var keys = key.split("."), value = data[keys.shift()]
- $.each(keys, function(){ value = value[this] })
- return value
- })
- }
-})(jQuery)
+ $.nano = function(template, data) {
+ return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
+ var keys = key.split("."), value = data[keys.shift()];
+ $.each(keys, function () { value = value[this]; });
+ return (value === null || value === undefined) ? "" : value;
+ });
+ };
+})(jQuery);

0 comments on commit 72098e9

Please sign in to comment.