Skip to content

Fix reject_nested_columns to consider parentheses and brackets#12

Merged
k0kubun merged 3 commits into
k0kubun:masterfrom
creasty:fix_attributes_parse_error
Apr 5, 2015
Merged

Fix reject_nested_columns to consider parentheses and brackets#12
k0kubun merged 3 commits into
k0kubun:masterfrom
creasty:fix_attributes_parse_error

Conversation

@creasty

@creasty creasty commented Apr 5, 2015

Copy link
Copy Markdown
Contributor

Input

%a{ data: { value: t('foo', count: 1) } }
%a{ data: { value: [count: 1] } }

Compiled result

in ~/Develop/creasty/hamlit on fix_attributes_parse_error *
❯ be hamlit parse tmp/in.haml
[:multi,
 [:html,
  :tag,
  "a",
  [:haml, :attrs, "{ data: { value: t('foo', count: 1) } }"],
  [:multi]],
 [:newline],
 [:static, "\n"],
 [:html,
  :tag,
  "a",
  [:haml, :attrs, "{ data: { value: [count: 1] } }"],
  [:multi]],
 [:newline],
 [:static, "\n"]]

in ~/Develop/creasty/hamlit on fix_attributes_parse_error *
❯ be hamlit compile tmp/in.haml
_buf = []; _buf << ("<a data-value='".freeze); _buf << (t('foo', count: 1); _buf << ("'></a>\n<a data-value='".freeze);
; _buf << ([count: 1); _buf << ("'></a>\n".freeze);
; _buf = _buf.join

in ~/Develop/creasty/hamlit on fix_attributes_parse_error *
❯ be hamlit render tmp/in.haml
/Users/ykiwng/Develop/creasty/hamlit/lib/hamlit/cli.rb:11:in `eval': (eval):2: syntax error, unexpected ')', expecting ']' (SyntaxError)
; _buf << ([count: 1); _buf << ("'></a>\n".freeze);
                     ^
(eval):3: syntax error, unexpected end-of-input, expecting ')'
; _buf = _buf.join
                  ^
    from /Users/ykiwng/Develop/creasty/hamlit/lib/hamlit/cli.rb:11:in `render'
    from /Users/ykiwng/Develop/creasty/hamlit/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/ykiwng/Develop/creasty/hamlit/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/ykiwng/Develop/creasty/hamlit/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/ykiwng/Develop/creasty/hamlit/vendor/bundle/ruby/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/ykiwng/Develop/creasty/hamlit/bin/hamlit:6:in `<top (required)>'
    from /Users/ykiwng/Develop/creasty/hamlit/vendor/bundle/ruby/2.2.0/bin/hamlit:23:in `load'
    from /Users/ykiwng/Develop/creasty/hamlit/vendor/bundle/ruby/2.2.0/bin/hamlit:23:in `<main>'

Look at the compiled result, here's a missing closing paren:

_buf << (t('foo', count: 1); _buf << ("'></a>\n<a data-value='".freeze);
                           ^

and a bracket also causes the error:

; _buf << ([count: 1); _buf << ("'></a>\n".freeze);
                     ^

@k0kubun

k0kubun commented Apr 5, 2015

Copy link
Copy Markdown
Owner

LGTM 👍
Thank you for your contribution! 😆

k0kubun added a commit that referenced this pull request Apr 5, 2015
Fix reject_nested_columns to consider parentheses and brackets
@k0kubun k0kubun merged commit 9232c55 into k0kubun:master Apr 5, 2015
@creasty creasty deleted the fix_attributes_parse_error branch April 5, 2015 09:46
@k0kubun

k0kubun commented Apr 5, 2015

Copy link
Copy Markdown
Owner

Released as v0.4.2 💎

@creasty

creasty commented Apr 5, 2015

Copy link
Copy Markdown
Contributor Author

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants