Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Allow set tag to use bracket notation for object properties #388

Merged
merged 1 commit into from
Jan 10, 2014
Merged

Allow set tag to use bracket notation for object properties #388

merged 1 commit into from
Jan 10, 2014

Conversation

hegemonic
Copy link
Contributor

In the current version of Swig, if you're using the set tag to assign a value to an object's property, you can't use bracket notation for the object property. For example, if you've already set the local variables foo = {} and bar = 'bar', any of the following will cause Swig to complain about an unexpected assignment:

{% set foo[bar] = "baz" %}
{% set foo['bar'] = "baz" %}
{% set foo["bar"] = "baz" %}

This pull request makes all of those examples work as you'd expect. It still behaves correctly if a quoted property name includes an assignment operator.

If you have any feedback on this pull request, I'd be happy to amend it.

(P.S. Thanks for creating such an excellent template engine!)

@hegemonic
Copy link
Contributor Author

I have no idea why the Travis CI build is failing on Node.js 0.8. I don't think it's related to my commit, since the tests also fail on master.

When I run the tests locally with Node.js 0.8.26, they all pass.

@bodokaiser
Copy link

@hegemonic
Have the same problem. Guess it is a small error in the tests. See: #381 (comment)

I think paul will fix this after doing his current pr work.

@paularmstrong paularmstrong merged commit dcc9de6 into paularmstrong:master Jan 10, 2014
@paularmstrong
Copy link
Owner

Merged!

I also added the ability to mix bracket and dot-notation.

As for the Node v0.8.x issues, I may just drop official support for 0.8.x. 0.10.x has been out for some time now.

@hegemonic
Copy link
Contributor Author

Excellent! Many thanks.

@hegemonic hegemonic deleted the set-tag branch January 11, 2014 00:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants