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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With