mikeric/rivets — pull request #224 by davidmcclure (2013-11-03 17:45:13+00:00)
Title: Fixes breakage when used with libraries that extend String.prototype

First of all, thanks for all the great work with rivets - really a pleasure to use! I ran into an odd problem yesterday, which turns out to be an easy fix - I'm using rivets alongside another Javascript library that (irresponsibly) monkey-patches extensions directly onto String.prototype. For a variety of frustrating reasons, I can't just drop this library, at least not in the near future. Eg, stuff like:

```javascript
String.prototype.startsWith = function() { ... }
```

When this is the case, the `KeypathParser.parse` methods breaks - the `for index, char of keypath` at line 11 compiles to `for (index in keypath)`, which has effect of iterating over the monkey-patched methods in addition to the characters in the string. The methods get tacked onto the end of the model keys as raw string values, which effectively breaks the entire library.

Anyway, the real problem is with the code that modifies `String`, not with rivets, but rivets can be hardened up against this just by changing the `for index, char of keypath` to `for char in keypath`, which compiles to a regular for loop (and the `index` reference isn't used anyway).