Skip to content

Commit 9079bd8

Browse files
committed
Add lint task using JSHint
1 parent f7e8434 commit 9079bd8

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

.jshintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"eqnull": true,
3+
"evil": true
4+
}
5+

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ task :minify do
2525
sh "uglifyjs mustache.js > #{minified_file}"
2626
end
2727

28+
desc "Run JSHint, requires jshint (see http://www.jshint.com)"
29+
task :lint do
30+
sh "jshint mustache.js"
31+
end
32+
2833
# Creates a task that uses the various template wrappers to make a wrapped
2934
# output file. There is some extra complexity because Dojo and YUI use
3035
# different final locations.

mustache.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
6464
}
6565

6666
function escapeRe(string) {
67-
return string.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
67+
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
6868
}
6969

7070
var entityMap = {
@@ -243,21 +243,25 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
243243
case "object":
244244
if (isArray(value)) {
245245
var buffer = "";
246+
246247
for (var i = 0, len = value.length; i < len; ++i) {
247248
buffer += callback(context.push(value[i]), this);
248249
}
250+
249251
return buffer;
250-
} else {
251-
return callback(context.push(value), this);
252252
}
253-
break;
253+
254+
return callback(context.push(value), this);
254255
case "function":
255-
var sectionText = callback(context, this), self = this;
256+
// TODO: The text should be passed to the callback plain, not rendered.
257+
var sectionText = callback(context, this),
258+
self = this;
259+
256260
var scopedRender = function (template) {
257261
return self.render(template, context);
258262
};
263+
259264
return value.call(context.view, sectionText, scopedRender) || "";
260-
break;
261265
default:
262266
if (value) {
263267
return callback(context, this);
@@ -549,7 +553,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
549553

550554
// The high-level clearCache, compile, compilePartial, and render functions
551555
// use this default renderer.
552-
var _renderer = new Renderer;
556+
var _renderer = new Renderer();
553557

554558
/**
555559
* Clears all cached templates and partials.

0 commit comments

Comments
 (0)