Skip to content

Commit

Permalink
more comment and documentation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikJoreteg committed Nov 13, 2010
1 parent 4069f61 commit b91e8a0
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 46 deletions.
29 changes: 13 additions & 16 deletions ICanHaz.js
@@ -1,18 +1,12 @@
/*!
ICanHaz.js version 0.7 -- by @HenrikJoreteg
Licensed under the "You should follow @HenrikJoreteg on Twitter to use this" license. (Because, apparently I'm a twitter whore like that)
Documentation at: http://github.com/HenrikJoreteg/ICanHaz.js
Dependencies:
- jQuery
ICanHaz comes bundled with mustache.js (MIT licensed) for convenience. Big ups to @defunkt for mustache and @janl for the js port.
https://github.com/janl/mustache.js/blob/master/LICENSE
More info at: http://github.com/HenrikJoreteg/ICanHaz.js
*/
(function ($) {
/*!
mustache.js — Logic-less templates in JavaScript
mustache.js -- Logic-less templates in JavaScript
by @janl (MIT Licensed, https://github.com/janl/mustache.js/blob/master/LICENSE).
See http://mustache.github.com/ for more info.
*/
Expand Down Expand Up @@ -98,7 +92,7 @@ var Mustache = function() {
*/
render_partial: function(name, context, partials) {
name = this.trim(name);
if(!partials || !partials[name]) {
if(!partials || partials[name] === undefined) {
throw({message: "unknown_partial '" + name + "'"});
}
if(typeof(context[name]) != "object") {
Expand All @@ -118,7 +112,7 @@ var Mustache = function() {
var that = this;
// CSW - Added "+?" so it finds the tighest bound, not the widest
var regex = new RegExp(this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag +
"\\s*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
"\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
"\\s*", "mg");

// for each {{#foo}}{{/foo}} section do...
Expand Down Expand Up @@ -273,8 +267,11 @@ var Mustache = function() {
create_context: function(_context) {
if(this.is_object(_context)) {
return _context;
} else if(this.pragmas["IMPLICIT-ITERATOR"]) {
var iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator || ".";
} else {
var iterator = ".";
if(this.pragmas["IMPLICIT-ITERATOR"]) {
iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
}
var ctx = {};
ctx[iterator] = _context;
return ctx;
Expand Down Expand Up @@ -315,7 +312,7 @@ var Mustache = function() {

return({
name: "mustache.js",
version: "0.3.0-dev",
version: "0.3.0",

/*
Turns a template and view into HTML
Expand All @@ -332,7 +329,7 @@ var Mustache = function() {
}
});
}();/*!
ICanHaz.js version 0.7 -- by @HenrikJoreteg
ICanHaz.js -- by @HenrikJoreteg
*/
/*global jQuery */
function ICanHaz() {
Expand Down
18 changes: 6 additions & 12 deletions ICanHaz.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -20,7 +20,7 @@ A simple/powerful approach for doing client-side templating with Mustache.js and
###Step 3. - There is no step 3!

##What else do I need to know?
For simplicity and ease of use, ICanHaz includes Mustache.js (inside a closure) that way you can just include `<script src="ICanHaz.min.js"></script>` along with jQuery and you're off *haz*'ing stuffs. Luckily Mustache and Mustache.js are generously MIT licensed. Mr. Github founder himself Chris Wanstrath ([@defunkt](http://twitter.com/defunkt)) created mustache. Read the [mustache documentation](http://mustache.github.com) for more info.
For simplicity and ease of use, ICanHaz includes [janl's Mustache.js v0.3.0](https://github.com/janl/mustache.js/tree/0.3.0), inside a closure) that way you can just include `<script src="ICanHaz.min.js"></script>` along with jQuery and you're off *haz*'ing stuffs. Luckily Mustache and Mustache.js are generously MIT licensed. Mr. Github founder himself Chris Wanstrath ([@defunkt](http://twitter.com/defunkt)) created mustache. Read the [mustache documentation](http://mustache.github.com) for more info. Then it was ported to JS by [Jan Lehnardt](https://github.com/janl).

##Why would we need this?
Because building html elements using javascript or jQuery is ugly:
Expand Down
12 changes: 2 additions & 10 deletions source/intro.js
@@ -1,12 +1,4 @@
/*!
ICanHaz.js version 0.7 -- by @HenrikJoreteg
Licensed under the "You should follow @HenrikJoreteg on Twitter to use this" license. (Because, apparently I'm a twitter whore like that)
Documentation at: http://github.com/HenrikJoreteg/ICanHaz.js
Dependencies:
- jQuery
ICanHaz comes bundled with mustache.js (MIT licensed) for convenience. Big ups to @defunkt for mustache and @janl for the js port.
https://github.com/janl/mustache.js/blob/master/LICENSE
ICanHaz.js version @VERSION@ -- by @HenrikJoreteg
More info at: http://github.com/HenrikJoreteg/ICanHaz.js
*/
2 changes: 1 addition & 1 deletion source/main.js
@@ -1,5 +1,5 @@
/*!
ICanHaz.js version @VERSION@ -- by @HenrikJoreteg
ICanHaz.js -- by @HenrikJoreteg
*/
/*global jQuery */
function ICanHaz() {
Expand Down
17 changes: 11 additions & 6 deletions source/mustache.js
@@ -1,5 +1,7 @@
/*!
mustache.js — Logic-less templates in JavaScript
mustache.js -- Logic-less templates in JavaScript
by @janl (MIT Licensed, https://github.com/janl/mustache.js/blob/master/LICENSE).
See http://mustache.github.com/ for more info.
*/
Expand Down Expand Up @@ -85,7 +87,7 @@ var Mustache = function() {
*/
render_partial: function(name, context, partials) {
name = this.trim(name);
if(!partials || !partials[name]) {
if(!partials || partials[name] === undefined) {
throw({message: "unknown_partial '" + name + "'"});
}
if(typeof(context[name]) != "object") {
Expand All @@ -105,7 +107,7 @@ var Mustache = function() {
var that = this;
// CSW - Added "+?" so it finds the tighest bound, not the widest
var regex = new RegExp(this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag +
"\\s*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
"\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
"\\s*", "mg");

// for each {{#foo}}{{/foo}} section do...
Expand Down Expand Up @@ -260,8 +262,11 @@ var Mustache = function() {
create_context: function(_context) {
if(this.is_object(_context)) {
return _context;
} else if(this.pragmas["IMPLICIT-ITERATOR"]) {
var iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator || ".";
} else {
var iterator = ".";
if(this.pragmas["IMPLICIT-ITERATOR"]) {
iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
}
var ctx = {};
ctx[iterator] = _context;
return ctx;
Expand Down Expand Up @@ -302,7 +307,7 @@ var Mustache = function() {

return({
name: "mustache.js",
version: "0.3.0-dev",
version: "0.3.0",

/*
Turns a template and view into HTML
Expand Down

0 comments on commit b91e8a0

Please sign in to comment.