Escape tokens for RegEx -- doesn't like {{$}}...{{/$}}
moos opened this issue · 3 comments
moos commented
_bridge function throws a type error
var data = {$ : true };
Mark.up("{{$}} jQuery was here {{/$}}", data);
// output
b = a + tags[0].length;
^
TypeError: Cannot read property 'length' of undefined`
$ is a perfectly valid (and oft-used) identifier. In fact $1
, abs$
, etc. all fail. So will any key name containing any other regex special character.
Consider using escapeRegExp
(see MDN Regular_Expressions page).
adammark commented
I can't quite follow what you're doing here. Are you passing jQuery as a context variable? If so, why?
I've tested various permutations of "$", including the character by itself, and Markup works as expected. Example:
var context = { $price: "123,456.78" };
Mark.up("price: {{$price}}", context) === "price: 123,456.78";
moos commented
Ignore jQuery -- this breaks when the bridge code is called, so you'll have to use price: {{$price}} ... {{/$prince}}
in your example to reproduce it.
adammark commented
Okay, I see now. Thanks for the catch—let me see what I can do.