Permalink
Browse files

docs

  • Loading branch information...
1 parent 40f7019 commit 4b8134e89f679e49407121c0e9574e350e14f3c2 @tj tj committed Sep 5, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 Readme.md
View
@@ -36,14 +36,24 @@ $ minstache < hello.mustache > hello.js
```js
module.exports = function anonymous(obj) {
+
function escape(html) {
return String(html)
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
};
- return "Hello " + escape(obj.name) + "! " + (!obj.authenticated ? "<a href=\"/login\">login</a>" : "") + ""
+
+ function section(obj, prop, negate, str) {
+ var val = obj[prop];
+ if ('function' == typeof val) return val.call(obj, str);
+ if (negate) val = !val;
+ if (val) return str;
+ return '';
+ };
+
+ return "Hello " + escape(obj.name) + "! " + section(obj, "authenticated", true, "<a href=\"/login\">login</a>") + "\n"
}
```

0 comments on commit 4b8134e

Please sign in to comment.