New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruby 3.1 shorthand syntax doesn't work for nested hashes #1138
Comments
I cannot reproduce the issue. $ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
$ haml version
6.2.3
$ cat /tmp/a.haml
- redirect_to = 'path'
- data = { dialog_target: 'redirect', redirect_to: }
%div{ data: }
$ haml render /tmp/a.haml
<div data-dialog-target='redirect' data-redirect-to='path'></div> Could you consider the following things and reopen this? Thanks in advance.
|
@k0kubun did you try it with the nesting happening on the element line? I see an error with the following template: - redirect_to = '/some/path'
%div{ data: { redirect_to: } } $ haml render /tmp/a.haml
(eval):1:in `compile_data!': undefined local variable or method `redirect_to' for #<Haml::AttributeCompiler:0x00007f4372837950 @identity=#<Haml::Identity:0x00007f437287b6a0 @unique_id=0>, @quote="'", @format=:html, @escape_attrs=true> (NameError)
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/attribute_compiler.rb:92:in `eval'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/attribute_compiler.rb:92:in `compile_data!'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/attribute_compiler.rb:59:in `block in static_compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/attribute_compiler.rb:49:in `each'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/attribute_compiler.rb:49:in `static_compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/attribute_compiler.rb:33:in `compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler/tag_compiler.rb:16:in `compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler.rb:87:in `compile_tag'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler.rb:50:in `compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler.rb:59:in `block in compile_children'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler/children_compiler.rb:20:in `block (2 levels) in compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler/children_compiler.rb:49:in `moving_lineno'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler/children_compiler.rb:20:in `block in compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler/children_compiler.rb:17:in `each'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler/children_compiler.rb:17:in `compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler.rb:59:in `compile_children'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler.rb:36:in `compile'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/compiler.rb:26:in `call'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `block in call'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `each'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `inject'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/temple-0.10.3/lib/temple/engine.rb:51:in `call'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/cli.rb:91:in `generate_code'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/cli.rb:15:in `render'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/base.rb:485:in `start'
from /home/fletch/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/haml-6.2.3/exe/haml:6:in `<top (required)>'
from /home/fletch/.asdf/installs/ruby/3.2.2/bin/haml:25:in `load'
from /home/fletch/.asdf/installs/ruby/3.2.2/bin/haml:25:in `<main>'
from /home/fletch/.asdf/installs/ruby/3.2.2/bin/ruby_executable_hooks:22:in `eval'
from /home/fletch/.asdf/installs/ruby/3.2.2/bin/ruby_executable_hooks:22:in `<main>' $ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
$ haml version
6.2.3 |
Oh, good point. I have no idea why I didn't try an example closer to what you provided. It appears that |
I have the following template:
And I render it by passing a local:
This raises an error:
The template works as expected, however, when I pull out the
data
hash:The text was updated successfully, but these errors were encountered: