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
There is an incompatibility with html/template. The empty escaped template value template.HTML("") is false an in if, just as the empty string is. But the zero value safehtml.HTML{} is true.
I have a PR to fix template.IsTrue, but unfortunately I think fixing template execution is harder. The text/template execution engine is used, and it seems to have its version of IsTrue hardcoded.
Probably best not to "fix" template.IsTrue if execution doesn't match it.
Maybe the best thing to do is to document clearly that if .X was previously a string or template.HTML and is now a safehtml.HTML or other safehtml type, one must replace
Thanks for flagging this, we'll take a look at possible solutions, although at the moment updating the documentation seems the most probable outcome. safehtml/template tries to be as close to a drop-in replacement as possible, but the migration will never be 100% transparent, and this could be another of those divergences.
Probably best not to "fix" template.IsTrue if execution doesn't match it.
Activity
jba commentedon Jun 30, 2020
I have a PR to fix
template.IsTrue, but unfortunately I think fixing template execution is harder. Thetext/templateexecution engine is used, and it seems to have its version ofIsTruehardcoded.Probably best not to "fix"
template.IsTrueif execution doesn't match it.jba commentedon Jun 30, 2020
Maybe the best thing to do is to document clearly that if
.Xwas previously a string ortemplate.HTMLand is now asafehtml.HTMLor othersafehtmltype, one must replacewith
5psf commentedon Jul 6, 2020
Thanks for flagging this, we'll take a look at possible solutions, although at the moment updating the documentation seems the most probable outcome.
safehtml/templatetries to be as close to a drop-in replacement as possible, but the migration will never be 100% transparent, and this could be another of those divergences.+1 for having a uniform behavior.