canjs / can-stache

Live binding handlebars templates
https://canjs.com/doc/can-stache.html
MIT License
10 stars 13 forks source link

Value isn’t properly read when the value is keyed with a dot in the iteratee #698

Closed mikemitchel closed 5 years ago

mikemitchel commented 5 years ago

How often can you reproduce it?

Description: If the value being iterated over has a dot in it's key, can-stache does not render that value. I added the question label, as replacing the for-of with just the for helper and using scope.key (as per @justinbmeyer suggestion) works just fine. It might be a bug, or it might just be bad syntax/usage of the for-of helper.

See the codepen below for an example of both uses, and the results.

Steps to reproduce: https://codepen.io/mikemitchel/pen/BePqvY?editors=1010

Expected results: I would expect the for-of helper to handle/escape the dot in the key and still render. @bmomberger-bitovi had suggested this fix in the Bitovi Community

It should escape dots in `key`, so:  `var value = new KeyObservable(object, key.replace(/\./g, "\\.");` (edited)

Actual results: it doth not render, alas

Environment:

Software Version
can-stache version ^4.15.2
Browser Chrome
Operating system MacOS