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
This haml template demonstrates various ways attribute substitution fails inside for loops:
.attributes-work-outside-loops
%a(href="#{links[1].url}" title="#{links[1].title}")= links[1].title
%a(href="#{links[2].url}" title="#{links[2].title}")= links[2].title
-# -# uncomment for crash
-# .accessing-tables-in-attributes-throws-error-in-loops
-# - for i,link in pairs(links) do
-# %a(href="#{link.url}" title="#{link.title}")= link.title
.simple-attributes-in-loops-dont-error-but-dont-replace-either-but-DO-work-outside-attributes
- for i,link in pairs(links) do
%a(href="#{i}" title="#{i}")= i
.this-workaround-for-loops-is-self-defeating
- for i,link in pairs(links) do
= "<a href='" .. link.url .. "' title='" .. link.title .. "'>" .. link.title .. "</a>"
.this-workaround-might-clobber-things
- for i,link in pairs(links) do
- locals["i"] = i
- locals["link"] = link
%a(href="#{link.url}" title="#{link.title}")= link.title
When the "crash" loop in the haml is uncommented, Lua 5.1.5 produces this error:
/home/redacted/local/bin/lua: /home/redacted/local/share/lua/5.1/haml/renderer.lua:139:
Error in bug.haml at line 7 (offset 278): attempt to index global 'link' (a nil value)
stack traceback:
[C]: in function 'error'
/home/redacted/local/share/lua/5.1/haml/renderer.lua:139: in function 'render'
/home/redacted/local/share/lua/5.1/haml.lua:67: in function </home/redacted/local/share/lua/5.1/haml.lua:64>
(tail call): ?
./demo.lua:21: in main chunk
[C]: ?
The text was updated successfully, but these errors were encountered:
This haml template demonstrates various ways attribute substitution fails inside for loops:
When stored in
bug.haml
and used in this Lua:it produces this output:
When the "crash" loop in the haml is uncommented, Lua 5.1.5 produces this error:
The text was updated successfully, but these errors were encountered: