Skip to content
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

incorrect postfix conditionals evaluation #3

Closed
dreyks opened this issue Dec 27, 2016 · 2 comments
Closed

incorrect postfix conditionals evaluation #3

dreyks opened this issue Dec 27, 2016 · 2 comments

Comments

@dreyks
Copy link

dreyks commented Dec 27, 2016

what <%= 'ever' if true %>

evaluates to an empty string

> eval Erbse::Engine.new.call("what <%= 'ever' if false %>")
 => ""
> Erbse::Parser.new.call("what <%= 'ever' if true %>")
 => [:multi]

==========

<% [].each do %>
  <% next if true %>
<% end %>

produces incorrect ruby syntax

> eval Erbse::Engine.new.call("<% [].each do %>\n<% next if true %>\n<% end %>")
SyntaxError: (eval):3: syntax error, unexpected keyword_end, expecting end-of-input
; end; _buf = _buf.join("".freeze)
     ^
        from (irb):8:in `eval'
        from (irb):8
        from /home/roma/.rvm/rubies/ruby-2.3.3/bin/irb:11:in `<main>'
> Erbse::Parser.new.call("<% [].each do %>\n<% next if true %>\n<% end %>")
 => [:multi, [:newline], [:block, " next if true ", [:multi, [:newline]]]]
@dreyks
Copy link
Author

dreyks commented Dec 27, 2016

workaround

Erbse::Parser.class_eval do
  remove_const 'BLOCK_EXPR'
  const_set 'BLOCK_EXPR', /^\s*\b(if|unless)\b|\sdo\s*$|\sdo\s+\|/
end

@apotonick
Copy link
Owner

Fixed in 0.1.2.

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

No branches or pull requests

2 participants