twigkit/tempo — pull request #87 by jameskopacz (2013-09-11 06:16:42+00:00)
Title: tag "if" ReferenceError: [field] is not defined.

I ran into a problem where the json returned from an api, then sent to Tempo would cause an error because 2 fields had similar names.

The fields: price and compareToPrice

compareToPrice is not always returned as a field but was being used in the template to display html if it did:
```javascript
{% if compareToPrice %}
do stuff
{% endif %}
```
What happens is that Tempo runs line 766 and throws the error:
```javascript
expr = expr.replace(new RegExp(member_regex, 'gi'), function (match) {
return 'i.' + match;
});
```
compareToPrice wouldn't exist as a field but 'price' does so the above returns: compareToi.Price

Might be possible to fix by changing regex? I don't know enough to do anything there so I just put the eval in a try/catch block that returns '' if it fails.