Repository: twigjs/twig.js (js)

Issue:
accessing an array element with a colon
I'm passing in a hydra json response, which includes an element with a key of 'hydra:member'.

My twig template is

```twig
<h3>
    {{ data['@type'] }}
</h3>
{% for d in data['hydra:member'] %}
{{ d.id }}
{% endfor %}
```

This throws an error

TwigException: Twig.expression.type.array.start cannot follow a Twig.expression.type.variable at template:4 near '[...'
 ERROR  Failed to compile with 1 errors                                                                                                                                                       Syntax Error: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)

My solution is to set a temporary variable and use it, but I'm wondering if there's a better way, or if this can be fixed.

```twig
{% set hack = 'hydra:member' %}
{% for d in data[hack] %}
{{ d.id }}
{% endfor %}
```

Thanks.  I think this library rocks. 


Pull request:
Allow colon inside Twig.expression.type.key.brackets.
Fixes #854

Not sure why the colon is needed in de regexp for Twig.expression.type.key.brackets, @willrowe can you elaborate?

If it is not needed, removing the colon in the regexp will fix this issue.

Patch:
diff --git a/src/twig.expression.js b/src/twig.expression.js
index 80a8b4d..69b33bb 100644
--- a/src/twig.expression.js
+++ b/src/twig.expression.js
@@ -913,7 +913,7 @@ module.exports = function (Twig) {
         },
         {
             type: Twig.expression.type.key.brackets,
-            regex: /^\[([^\]:]*)\]/,
+            regex: /^\[([^\]]*)\]/,
             next: Twig.expression.set.operationsExtended.concat([
                 Twig.expression.type.parameter.start
             ]),


Test patch:
diff --git a/test/test.expressions.js b/test/test.expressions.js
index fb41428..b657766 100644
--- a/test/test.expressions.js
+++ b/test/test.expressions.js
@@ -325,6 +325,11 @@ describe('Twig.js Expressions ->', function () {
             const testTemplate = twig({data: '{% if a is defined and a %}true{% else %}false{% endif %}'});
             testTemplate.render({a: ['value']}).should.equal('true');
         });
+
+        it('should be able to access array elements with colons', function () {
+            const testTemplate = twig({data: '{% for d in data["test:element"] %}{{ d.id }}{% endfor %}'});
+            testTemplate.render({data: {'test:element':[{'id': 100}]}}).should.equal('100');
+        });
     });
 
     describe('Other Operators ->', function () {