Browse files

minor style fixes

  • Loading branch information...
1 parent 873344f commit d95605c23669e0eaae0a084f777adb432771424d @amccollum committed Dec 4, 2011
Showing with 17 additions and 19 deletions.
  1. +2 −1 lib/ender.js
  2. +9 −12 lib/wings.js
  3. +6 −6 src/wings/wings.coffee
View
3 lib/ender.js
@@ -1,3 +1,4 @@
+
(function($) {
var renderTemplate;
renderTemplate = require('wings').renderTemplate;
@@ -9,4 +10,4 @@
return renderTemplate(this[0].innerHTML, data, links);
}
}, true);
-})(ender);
+})(ender);
View
21 lib/wings.js
@@ -1,5 +1,6 @@
+
(function(wings) {
- var escapeXML, isArray, parse_re, renderRawTemplate, replaceBraces, restoreBraces, _ref;
+ var escapeXML, isArray, parsePattern, renderRawTemplate, replaceBraces, restoreBraces, _ref;
wings.strict = false;
wings.renderTemplate = function(template, data, links) {
template = replaceBraces(template);
@@ -32,13 +33,13 @@
}
});
};
- parse_re = /\s*\{([:!])\s*([^}]*?)\s*\}([\S\s]+?)\s*\{\/\s*\2\s*\}|\{(\#)\s*[\S\s]+?\s*\#\}|\{([@&]?)\s*([^}]*?)\s*\}/mg;
+ parsePattern = /\s*\{([:!])\s*([^}]*?)\s*\}([\S\s]+?)\s*\{\/\s*\2\s*\}|\{(\#)[\S\s]+?\#\}|\{([@&]?)\s*([^}]*?)\s*\}/mg;
return renderRawTemplate = function(template, data, links) {
- return template.replace(parse_re, function(all, section_op, section_name, section_content, comment_op, tag_op, tag_name) {
+ return template.replace(parsePattern, function(all, sectionOp, sectionName, sectionContent, commentOp, tagOp, tagName) {
var content, i, link, name, op, part, parts, rest, v, value, _len, _ref2;
- op = section_op || comment_op || tag_op;
- name = section_name || tag_name;
- content = section_content;
+ op = sectionOp || commentOp || tagOp;
+ name = sectionName || tagName;
+ content = sectionContent;
switch (op) {
case ':':
value = data[name];
@@ -111,14 +112,10 @@
} else if (typeof value === 'function') {
value = value.call(data);
}
- if (op === '&') {
- return value;
- } else {
- return escapeXML(value);
- }
+ return (op === '&' ? value : escapeXML(value));
default:
throw "Invalid section op: " + op;
}
});
};
-})(typeof exports !== "undefined" && exports !== null ? exports : (this['wings'] = {}));
+})(typeof exports !== "undefined" && exports !== null ? exports : (this['wings'] = {}));
View
12 src/wings/wings.coffee
@@ -22,17 +22,17 @@
when '>' then return '>'
else return s
- parse_re = ///
+ parsePattern = ///
\s* \{([:!]) \s* ([^}]*?) \s* \} ([\S\s]+?) \s* \{/ \s* \2 \s*\} | # sections
- \{(\#) \s* [\S\s]+? \s* \#\} | # comments
+ \{(\#) [\S\s]+? \#\} | # comments
\{([@&]?) \s* ([^}]*?) \s* \} # tags
///mg
renderRawTemplate = (template, data, links) ->
- template.replace parse_re, (all, section_op, section_name, section_content, comment_op, tag_op, tag_name) ->
- op = section_op or comment_op or tag_op
- name = section_name or tag_name
- content = section_content
+ template.replace parsePattern, (all, sectionOp, sectionName, sectionContent, commentOp, tagOp, tagName) ->
+ op = sectionOp or commentOp or tagOp
+ name = sectionName or tagName
+ content = sectionContent
switch op
when ':' # section

0 comments on commit d95605c

Please sign in to comment.