You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.
In order to support the @safe and @escape helpers, eco adds these to the context object, which can make for confusing bugs.
Here's a very simplified version of where I ran into the problem:
sales= ({price: i, shipping:i, tax:i} for i in [0..10])
tpl=eco.compile"Price: <%= @price %>; Shipping: <%= @shipping %>; Tax: <%= @tax %><br>"totals=price:0shipping:0tax:0for s in sales
console.logtpl s
totals[k] += v for k,v of s
console.logtpl totals
The problem is calling tpl pollutes s with the escape property, which then gets concatenated repeatedly onto totals.escape. As a result, we end up with a garbled function string that begins "undefinedfunction (value)...". Then when we call tpl totals, this eco tries to call that garbled string as a function, and we get an error which was rather confusing to pin down.
For now, I'm working around this by shallow copying my inputs. But this is really not how a template library should be treating its inputs. Any changes made on the context object should be reversed before returning.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In order to support the
@safe
and@escape
helpers, eco adds these to the context object, which can make for confusing bugs.Here's a very simplified version of where I ran into the problem:
The problem is calling
tpl
pollutess
with theescape
property, which then gets concatenated repeatedly onto totals.escape. As a result, we end up with a garbled function string that begins"undefinedfunction (value)..."
. Then when we calltpl totals
, this eco tries to call that garbled string as a function, and we get an error which was rather confusing to pin down.For now, I'm working around this by shallow copying my inputs. But this is really not how a template library should be treating its inputs. Any changes made on the context object should be reversed before returning.
The text was updated successfully, but these errors were encountered: