Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERB doesn't recognize -%> tag

When I run this line:

ERB.new("<%= 'hi' %>").result

It works fine and I get this output: "hi"

But when I run this line:

ERB.new("<%= 'hi' -%>").result

I get this error:

SyntaxError: compile error
(erb):1: syntax error, unexpected ')'
_erbout = ''; _erbout.concat(( 'hi' -).to_s); _erbout

How can I fix this?

like image 389
Oded Harth Avatar asked Dec 17 '22 07:12

Oded Harth


1 Answers

You need to set trim_mode parameter to '-':

ERB.new("<%= 'hi' -%>", nil, '-').result

If using CLI, set it via -T -:

erb -T - -r ./variables.rb template.erb

like image 124
Petr Avatar answered Dec 18 '22 21:12

Petr