mbosecke/pebble — pull request #37 by gered (2014-10-04 20:29:26+00:00)
Title: Add "subscript syntax" support for accessing attributes

This adds an alternate syntax for accessing attributes for values inside the context map. It would be very useful if your context map contained keys with otherwise invalid characters in the key name (such as hyphens).

Currently

{{ person.first-name }}

results in:

Exception in thread "main" java.lang.RuntimeException: invalid operands for mathematical operator [+]

With this addition, you can now do this:

{{ person['first-name'] }}

And can chain them together the same way you can access multi-layered nested values with the dot '.' syntax.