From b97809ce441b4cec6051f010f3191b576b8af4f2 Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Thu, 23 Feb 2012 07:49:49 -0800 Subject: [PATCH 01/10] Fixing dateformats `N` and `w` --- lib/dateformat.js | 7 ++++--- lib/filters.test.js | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/dateformat.js b/lib/dateformat.js index 9b81040b..c13d455c 100644 --- a/lib/dateformat.js +++ b/lib/dateformat.js @@ -12,7 +12,7 @@ var _ = require('underscore'), /* DateZ is licensed under the MIT License: Copyright (c) 2011 Tomo Universalis (http://tomouniversalis.com) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ @@ -112,14 +112,15 @@ exports.l = function (input) { return _days.full[input.getDay()]; }; exports.N = function (input) { - return input.getDay(); + var d = input.getDay(); + return (d >= 1) ? d + 1 : 7; }; exports.S = function (input) { var d = input.getDate(); return (d % 10 === 1 && d !== 11 ? 'st' : (d % 10 === 2 && d !== 12 ? 'nd' : (d % 10 === 3 && d !== 13 ? 'rd' : 'th'))); }; exports.w = function (input) { - return input.getDay() - 1; + return input.getDay(); }; exports.z = function (input, offset, abbr) { var year = input.getFullYear(), diff --git a/lib/filters.test.js b/lib/filters.test.js index 2a6ce81a..b7df0db2 100644 --- a/lib/filters.test.js +++ b/lib/filters.test.js @@ -60,9 +60,9 @@ exports.date = function (test) { testFormat('D', 'Tue'); testFormat('j', '6'); testFormat('l', 'Tuesday'); - testFormat('N', '2'); + testFormat('N', '3'); testFormat('S', 'th'); - testFormat('w', '1'); + testFormat('w', '2'); testFormat('z', '248'); testFilter(test, 'date("z", 480)', { v: makeDate(480, 2011, 0, 1) }, '0', 'z'); testFilter(test, 'date("z", 480)', { v: makeDate(480, 2011, 11, 31) }, '364', 'z'); @@ -112,6 +112,21 @@ exports.date = function (test) { testFormat('r', 'Tue, 06 Sep 2011 16:05:02 GMT'); testFormat('U', '1315325102'); + // More complete S ordinal testing + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 1) }, 'st', 'S 1st'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 2) }, 'nd', 'S 2nd'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 3) }, 'rd', 'S 3rd'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 4) }, 'th', 'S 4th'); + testFilter(test, 'date("w", 420)', { v: makeDate(420, 2011, 8, 4) }, '0', 'w 0'); + testFilter(test, 'date("N", 420)', { v: makeDate(420, 2011, 8, 4) }, '7', 'N 7'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 10) }, 'th', 'S 10th'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 11) }, 'th', 'S 11th'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 12) }, 'th', 'S 12th'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 13) }, 'th', 'S 13th'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 21) }, 'st', 'S 21st'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 22) }, 'nd', 'S 22nd'); + testFilter(test, 'date("S", 420)', { v: makeDate(420, 2011, 8, 23) }, 'rd', 'S 23rd'); + test.done(); }; From 8d8a980666aa218f4476d51443a937fd800e34ac Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Mon, 27 Feb 2012 19:53:45 -0800 Subject: [PATCH 02/10] update custom tags docs for parser change --- docs/custom-tags.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/custom-tags.md b/docs/custom-tags.md index 5b9e191f..797dcf2d 100644 --- a/docs/custom-tags.md +++ b/docs/custom-tags.md @@ -10,14 +10,13 @@ First, make sure to include your node.js file that declares your tags in the swi Requirements # ------------ -First, include the Swig parser and helpers. +First, include the helpers. - var parser = require('swig/lib/parser'), - helpers = require('swig/lib/helpers'); + var helpers = require('swig/lib/helpers'); Define your tag and whether or not it requires an "end" tag: - exports.mytag = function (indent, parentBlock) { + exports.mytag = function (indent, parentBlock, parser) { return 'output'; }; exports.mytag.ends = true; @@ -27,7 +26,7 @@ A Really Simple Tag # To parse a swig variable with or without filters into a variable token, eg. `bar` or `foo|lowercase` - exports.mytag = function (indent, parentBlock) { + exports.mytag = function (indent, parentBlock, parser) { var myArg = parser.parseVariable(this.args[0]); return 'output'; }; @@ -35,7 +34,7 @@ To parse a swig variable with or without filters into a variable token, eg. `bar Use a parsed variable token with `helpers.setVar()` to bind a variable in your current scope into the templates scope. The `setVar` method cleans up variable output, applies filters and escaping for clean output: - exports.mytag = function (indent, parentBlock) { + exports.mytag = function (indent, parentBlock, parser) { var myArg = parser.parseVariable(this.args[0]), output = ''; output += helpers.setVar(name, myArg); @@ -45,7 +44,7 @@ Use a parsed variable token with `helpers.setVar()` to bind a variable in your c To parse the inner content of a tag for outputting, use `parser.compile.apply(this, [indent, parentBlock])`: - exports.mytag = function (indent, parentBlock) { + exports.mytag = function (indent, parentBlock, parser) { var myArg = parser.parseVariable(this.args[0]), output = []; @@ -87,7 +86,7 @@ To access a third-party library or method that is defined outside of your templa Once you've added it, your custom tag can reference the `i18next` extension via the `_ext` object: - exports.trans = function (indent, parentBlock) { + exports.trans = function (indent, parentBlock, parser) { var myArg = parser.parseVariable(this.args[0]), output = []; output.push(helpers.setVar('__myArg', myArg)); From 583df10613360f9a6431b7ee074ab7f862fe3afc Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Mon, 27 Feb 2012 19:56:31 -0800 Subject: [PATCH 03/10] version bump v0.11.0 --- History.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index d7eb6cde..9e080b07 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,19 @@ +[0.11.0](https://github.com/paularmstrong/swig/tree/v0.11.0) / 2012-02-27 +------------------------------------------------------------------------ + +* **Added** Support for Windows style paths [gh-57] +* **Added** `ignore missing` tokens to include tag +* **Changed** include tag `with context` to only work if `context` is an object +* **Changed** `autoescape` tag controls no longer 'yes' or 'no'. Use `true` and `false` +* **Changed** parser is now passed into tags as an argument +* **Changed** don't require passing context object when rendering template +* **Fixed** dateformats `N` and `w` [gh-59] +* **Fixed** number changing to string after add filter or set from variable [gh-53] [gh-58] +* **Fixed** speed decrease caused by loop.cycle fixed +* **Fixed** Ensure set tag bubbles through extends and blocks + +[Documentation](https://github.com/paularmstrong/swig/tree/v0.11.0/docs) + [0.10.0](https://github.com/paularmstrong/swig/tree/v0.10.0) / 2012-02-13 ------------------------------------------------------------------------ diff --git a/package.json b/package.json index c0a0c228..d9a511df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swig", - "version": "0.10.0", + "version": "0.11.0", "description": "A fast django-like templating engine for node.js and browsers.", "keywords": ["template", "templating", "html", "django", "express", "block"], "repository": { From fdcc8db1b00c370819ed9d92d567563c142f88c9 Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Mon, 20 Feb 2012 20:07:36 -0800 Subject: [PATCH 04/10] removing unnecessary loop.cycle reset --- lib/tags/for.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/tags/for.js b/lib/tags/for.js index 6c5612d4..a3713d52 100644 --- a/lib/tags/for.js +++ b/lib/tags/for.js @@ -40,7 +40,6 @@ module.exports = function (indent, parentBlock, parser) { out = '(function () {\n' + ' var loop = {}, __loopKey, __loopIndex = 0, __loopLength = 0,' + ' __ctx_operand = _context["' + operand1 + '"],\n' + - ' __ctx_cycle = (typeof loop_cycle !== "undefined") ? loop_cycle : null,\n' + ' loop_cycle = function() {\n' + ' var args = _.toArray(arguments), i = loop.index0 % args.length;\n' + ' return args[i];\n' + @@ -65,7 +64,6 @@ module.exports = function (indent, parentBlock, parser) { loopShared + ' }\n' + ' }\n' + - ' loop_cycle = __ctx_cycle;\n' + ' _context["' + operand1 + '"] = __ctx_operand;\n' + '})();\n'; From 0a9c503a24c4664c4ef7e6304289df4ffd86f2a8 Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Sun, 1 Apr 2012 12:52:17 -0700 Subject: [PATCH 05/10] don't remove duplicate tokens when extending fixes gh-67 --- lib/parser.js | 2 +- lib/parser.test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index 1d8b6e7f..78f99a8c 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -347,7 +347,7 @@ exports.compile = function compile(indent, parentBlock) { if (tokens.length && tokens[0].name === 'extends') { this.blocks = _.extend({}, this.parent.blocks, this.blocks); - this.tokens = _.union(sets, this.parent.tokens); + this.tokens = sets.concat(this.parent.tokens); } sets = tokens = null; } diff --git a/lib/parser.test.js b/lib/parser.test.js index 5f7db9d0..dd17f238 100644 --- a/lib/parser.test.js +++ b/lib/parser.test.js @@ -396,5 +396,12 @@ exports.Compiling = testCase({ eval('var _output = "";' + parser.compile.call(template, '')); }, 'block should throw if nested'); test.done(); + }, + + 'duplicate strings are not removed when extended': function (test) { + var dummy = swig.compile('"{{ e }}"{{ f }}"{{ g }}"{{ h }}', { filename: 'foo' }), + tpl = '{% extends "foo" %}'; + test.strictEqual(swig.compile(tpl)({ e: 'e', f: 'f', g: 'g', h: 'h' }), '"e"f"g"h', 'render extended'); + test.done(); } }); From 2cf13290e1491f19584544cf818e6f784678688c Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Sun, 1 Apr 2012 12:54:04 -0700 Subject: [PATCH 06/10] version bump v0.11.1 --- History.md | 11 +++++++++-- package.json | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index 9e080b07..82456391 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,12 @@ +[0.11.1](https://github.com/paularmstrong/swig/tree/v0.11.1) / 2012-04-01 +------------------------------------------------------------------------- + +* **Fixed** Duplicate (string) tokens were being removed when extending a base template. [gh-67] + +[Documentation](https://github.com/paularmstrong/swig/tree/v0.11.1/docs) + [0.11.0](https://github.com/paularmstrong/swig/tree/v0.11.0) / 2012-02-27 ------------------------------------------------------------------------- +------------------------------------------------------------------------- * **Added** Support for Windows style paths [gh-57] * **Added** `ignore missing` tokens to include tag @@ -15,7 +22,7 @@ [Documentation](https://github.com/paularmstrong/swig/tree/v0.11.0/docs) [0.10.0](https://github.com/paularmstrong/swig/tree/v0.10.0) / 2012-02-13 ------------------------------------------------------------------------- +------------------------------------------------------------------------- * **Added** loop.index0, loop.revindex, loop.revindex0, and loop.cycle [gh-48] * **Added** init config `extensions` for 3rd party extension access in custom tags [gh-44] diff --git a/package.json b/package.json index d9a511df..99318ba7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swig", - "version": "0.11.0", + "version": "0.11.1", "description": "A fast django-like templating engine for node.js and browsers.", "keywords": ["template", "templating", "html", "django", "express", "block"], "repository": { @@ -31,4 +31,4 @@ "bugs": { "url": "https://github.com/paularmstrong/swig/issues" } -} \ No newline at end of file +} From c526245920111e2946561cf29ecb17f412239aba Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Mon, 9 Apr 2012 07:57:22 -0700 Subject: [PATCH 07/10] remove need for runlint/runtest scripts resolved into makefile switched nodeunit reporter to skip_passed --- Makefile | 16 +++--- scripts/config-lint.js | 5 -- scripts/config-test.js | 5 -- scripts/runlint.js | 35 ------------ scripts/runtests.js | 124 ----------------------------------------- 5 files changed, 9 insertions(+), 176 deletions(-) delete mode 100644 scripts/config-test.js delete mode 100644 scripts/runlint.js delete mode 100644 scripts/runtests.js diff --git a/Makefile b/Makefile index d7942982..1056ac7f 100644 --- a/Makefile +++ b/Makefile @@ -6,14 +6,16 @@ all: browser: @scripts/browser.sh +tests := $(shell find . -name '*.test.js' ! -path "*node_modules/*" ! -path "*dist/*") +reporter = skip_passed test: - @node tests/speed.js - @node scripts/runtests.js - -testf: - @node_modules/nodeunit/bin/nodeunit ${file} + @node_modules/nodeunit/bin/nodeunit --reporter ${reporter} ${tests} +files := $(shell find . -name '*.js' ! -path "*node_modules/*" ! -path "*dist/*") lint: - @node scripts/runlint.js + @node_modules/nodelint/nodelint ${files} --config=scripts/config-lint.js + +speed: + @node tests/speed.js -.PHONY: all browser test lint \ No newline at end of file +.PHONY: all browser test lint speed \ No newline at end of file diff --git a/scripts/config-lint.js b/scripts/config-lint.js index 783eada1..e6bb58df 100644 --- a/scripts/config-lint.js +++ b/scripts/config-lint.js @@ -1,8 +1,3 @@ -module.exports = { - root: __dirname + '/../', - pathIgnore: ['*node_modules*', '*browser/underscore*', '*dist/browser/*', '*dist/test*'] -}; - var options = { adsafe: false, bitwise: true, diff --git a/scripts/config-test.js b/scripts/config-test.js deleted file mode 100644 index 85609166..00000000 --- a/scripts/config-test.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - root: __dirname + '/../', - testRunner: 'default', - pathIgnore: ['*node_modules*', '*dist/test*'] -}; diff --git a/scripts/runlint.js b/scripts/runlint.js deleted file mode 100644 index 79d012cb..00000000 --- a/scripts/runlint.js +++ /dev/null @@ -1,35 +0,0 @@ -var util = require('util'), - child_process = require('child_process'), - configFile = __dirname + '/config-lint', - ignore = '', - config, - root, - i; - -process.argv.forEach(function (val, index, array) { - if (index < 2) { - return; - } - - if (val === '-c') { - configFile = process.argv[~~index + 1]; - } -}); - -config = require(configFile); - -function runLint(error, stdout, stderr) { - var files = stdout.trim().replace(/\n/g, ' '); - - child_process.exec('node ' + __dirname + '/../node_modules/nodelint/nodelint ' + files + ' --config ' + configFile + '.js', { cwd: config.root }, function (error, stdout, stderr) { - util.puts(stdout); - }); -} - -i = config.pathIgnore.length; -while (i) { - i -= 1; - ignore += ' ! -path "' + config.pathIgnore[i] + '"'; -} - -child_process.exec('find . -name "*.js"' + ignore, { cwd: config.root }, runLint); diff --git a/scripts/runtests.js b/scripts/runtests.js deleted file mode 100644 index fc494526..00000000 --- a/scripts/runtests.js +++ /dev/null @@ -1,124 +0,0 @@ -var util = require('util'), - child_process = require('child_process'), - nodeunit = require('nodeunit'), - configFile = __dirname + '/config-test', - ignore = '', - path = require('path'), - fs = require('fs'), - track = require(__dirname + '/../node_modules/nodeunit/lib/track'), - utils = require(__dirname + '/../node_modules/nodeunit/lib/utils'), - AssertionError = require(__dirname + '/../node_modules/nodeunit/lib/assert').AssertionError, - config, - i, - l; - -process.argv.forEach(function (val, index, array) { - if (index < 2) { - return; - } - - if (val === '-c') { - configFile = process.argv[~~index + 1]; - } -}); - -config = require(configFile); - -/*! - * Nodeunit - * Copyright (c) 2010 Caolan McMahon - * MIT Licensed - */ -function run(files, options) { - - if (!options) { - options = JSON.parse(fs.readFileSync(__dirname + '/../node_modules/nodeunit/bin/nodeunit.json', 'utf8')); - } - - var content, - names, - i = 0, - error = function (str) { - return options.error_prefix + str + options.error_suffix; - }, - ok = function (str) { - return options.ok_prefix + str + options.ok_suffix; - }, - bold = function (str) { - return options.bold_prefix + str + options.bold_suffix; - }, - assertion_message = function (str) { - return options.assertion_prefix + str + options.assertion_suffix; - }, - start = new Date().getTime(), - paths = files.map(function (p) { - return path.join(process.cwd(), p); - }), - tracker = track.createTracker(function (tracker) { - if (tracker.unfinished()) { - console.log(''); - console.log(error(bold( - 'FAILURES: Undone tests (or their setups/teardowns): ' - ))); - names = tracker.names(); - for (i; i < names.length; i += 1) { - console.log('- ' + names[i]); - } - console.log(''); - console.log('To fix this, make sure all tests call test.done()'); - process.reallyExit(tracker.unfinished()); - } - }); - - nodeunit.runFiles(paths, { - testspec: options.testspec, - moduleStart: function (name) { - console.log('\n' + bold(name)); - }, - testDone: function (name, assertions) { - tracker.remove(name); - - if (!assertions.failures()) { - console.log('✔ ' + name); - } else { - console.log(error('✖ ' + name) + '\n'); - assertions.forEach(function (a) { - if (a.failed()) { - a = utils.betterErrors(a); - if (a.error instanceof AssertionError && a.message) { - console.log('Assertion Message: ' + assertion_message(a.message)); - } - console.log(a.error.stack + '\n'); - } - }); - } - }, - done: function (assertions, end) { - end = end || new Date().getTime(); - var duration = end - start; - if (assertions.failures()) { - console.log('\n' + bold(error('FAILURES: ')) + assertions.failures() + '/' + assertions.length + ' assertions failed (' + assertions.duration + 'ms)'); - process.exit(1); - } else { - console.log('\n' + bold(ok('OK: ')) + assertions.length + ' assertions (' + assertions.duration + 'ms)'); - } - }, - testStart: function (name) { - tracker.put(name); - } - }); -} - -function runTests(error, stdout, stderr) { - var tests = stdout.trim().split("\n"); - if (tests.length && tests[0] !== '') { - run(tests); - } -} - -l = config.pathIgnore.length; -for (i = 0; i < l; i += 1) { - ignore += ' ! -path "' + config.pathIgnore[i] + '"'; -} - -child_process.exec('find . -name "*.test.js" ' + ignore, { cwd: config.root }, runTests); From 5fbeca08f42c9ae0f4f9c918ac4bd563073ec3a5 Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Tue, 10 Apr 2012 17:53:44 -0700 Subject: [PATCH 08/10] Fix Underscore 1.3.2+ _.uniq() can't take undef Fixes gh-70 Fixes gh-71 --- lib/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index 78f99a8c..a3c258f9 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -258,7 +258,7 @@ exports.parse = function (data, tags, autoescape) { line: curline, name: tagname, compile: tags[tagname], - parent: _.uniq(stack[stack.length - 2]), + parent: _.uniq(stack[stack.length - 2] || []), strip: { before: stripBefore, after: stripAfter, From 84bcd14acfbdd1b5251bc5fc6fac177cda74a64e Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Tue, 10 Apr 2012 19:48:10 -0700 Subject: [PATCH 09/10] appeasing crockford and jslint --- index.js | 11 +++++------ lib/filters.js | 13 ++++++------- lib/helpers.js | 6 +++--- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 2770f469..db82dfbe 100644 --- a/index.js +++ b/index.js @@ -91,12 +91,11 @@ function createTemplate(data, id) { template.render = function (context, parents) { if (_config.allowErrors) { return render.call(this, context, parents, _config.filters, _, _config.extensions); - } else { - try { - return render.call(this, context, parents, _config.filters, _, _config.extensions); - } catch (e) { - return new TemplateError(e); - } + } + try { + return render.call(this, context, parents, _config.filters, _, _config.extensions); + } catch (e) { + return new TemplateError(e); } }; diff --git a/lib/filters.js b/lib/filters.js index 15ae9ba6..6e84b0f4 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -99,9 +99,8 @@ exports.escape = exports.e = function (input, type) { .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); - } else { - return input; } + return input; }; exports.first = function (input) { @@ -119,15 +118,16 @@ exports.first = function (input) { exports.join = function (input, separator) { if (_.isArray(input)) { return input.join(separator); - } else if (typeof input === 'object') { + } + + if (typeof input === 'object') { var out = []; _.each(input, function (value, key) { out.push(value); }); return out.join(separator); - } else { - return input; } + return input; }; exports.json_encode = function (input) { @@ -171,9 +171,8 @@ exports.replace = function (input, search, replacement, flags) { exports.reverse = function (input) { if (_.isArray(input)) { return input.reverse(); - } else { - return input; } + return input; }; exports.striptags = function (input) { diff --git a/lib/helpers.js b/lib/helpers.js index 4feaa775..c5df2003 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -116,9 +116,8 @@ function check(variable, context) { output[output.length - 1] = _.last(output).replace(/\] !== "undefined"$/, '_' + prop + '] !== "undefined"'); chain = chain.replace(/\]$/, '_' + prop + ']'); return; - } else { - chain += '[___' + prop + ']'; } + chain += '[___' + prop + ']'; } else { chain += '[' + prop + ']'; } @@ -149,7 +148,8 @@ exports.escapeVarName = function (variable, context) { if (exports.isLiteral(variable)) { return variable; - } else if (typeof context === 'string' && context.length) { + } + if (typeof context === 'string' && context.length) { variable = context + '.' + variable; } From b40f61fae34ef99dc801501e3f1c5c8e0a1c918f Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Tue, 10 Apr 2012 19:51:11 -0700 Subject: [PATCH 10/10] version bump 0.11.2 --- History.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index 82456391..effe6fdb 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,10 @@ +[0.11.2](https://github.com/paularmstrong/swig/tree/v0.11.2) / 2012-04-10 +------------------------------------------------------------------------- + +* **Fixed** Update support for underscore@1.3.3 [gh-70] [gh-71] + +[Documentation](https://github.com/paularmstrong/swig/tree/v0.11.2/docs) + [0.11.1](https://github.com/paularmstrong/swig/tree/v0.11.1) / 2012-04-01 ------------------------------------------------------------------------- diff --git a/package.json b/package.json index 99318ba7..38e00405 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swig", - "version": "0.11.1", + "version": "0.11.2", "description": "A fast django-like templating engine for node.js and browsers.", "keywords": ["template", "templating", "html", "django", "express", "block"], "repository": {