Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

critical fix for if negation. version 0.2.3

  • Loading branch information...
commit 1320a3b89da3e02e2abfc07be3dfcf762f10e767 1 parent d714c00
@paularmstrong authored
Showing with 15 additions and 3 deletions.
  1. +8 −0 History.md
  2. +2 −2 lib/tags.js
  3. +1 −1  package.json
  4. +4 −0 tests/tags.test.js
View
8 History.md
@@ -1,3 +1,11 @@
+## [0.2.3](https://github.com/paularmstrong/swig/tree/0.2.3) / 2011-09-16
+
+* **Fixed** Critical fix for negations in `if` blocks.
+* **Added** Support for `forloop.first` in `for` blocks.
+* **Added** Support for `forloop.last` in `for` blocks.
+* **Added** Support for `forloop.key` in `for` blocks.
+* **Added** Support for `{% empty %}` in `for` blocks.
+
## [0.2.2](https://github.com/paularmstrong/swig/tree/0.2.2) / 2011-09-16
* **Added** Support for `else if ...` within `if` blocks.
View
4 lib/tags.js
@@ -51,9 +51,9 @@ function checkIfArgs(leftOperand, operator, rightOperand) {
var negation = false;
// Check if there is negation
- if (leftOperand[0] === '!') {
+ if (leftOperand.name[0] === '!') {
negation = true;
- leftOperand = leftOperand.substr(1);
+ leftOperand.name = leftOperand.name.substr(1);
}
// '!something == else' - this syntax is forbidden. Use 'something != else' instead
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "swig",
- "version": "0.2.2",
+ "version": "0.2.3",
"description": "A fast django-like templating engine for node.js.",
"keywords": ["template", "html", "django", "sandbox"],
"repository": "git://github.com/paularmstrong/swig.git",
View
4 tests/tags.test.js
@@ -27,6 +27,10 @@ exports.if = testCase({
basic: function (test) {
var tmpl8 = swig.fromString('{% if foo %}hi!{% endif %}{% if bar %}nope{% endif %}');
test.strictEqual(tmpl8.render({ foo: 1, bar: false }), 'hi!');
+
+ tmpl8 = swig.fromString('{% if !foo %}hi!{% endif %}{% if !bar %}nope{% endif %}');
+ test.strictEqual(tmpl8.render({ foo: 1, bar: false }), 'nope');
+
test.done();
},
Please sign in to comment.
Something went wrong with that request. Please try again.