ruby - How to prevent Rails from showing an empty line in the source code if condition is false? -
ruby - How to prevent Rails from showing an empty line in the source code if condition is false? -
in rails 4 app have taghelper
function:
def robots_tag if important_page? tag(:meta, :name => "robots", :content => "dofollow") end end
in main layout using this:
<head> <%= robots_tag %> </head>
how can prevent rails showing empty line in source code if important_page?
false
?
thanks help.
try adding minus sign @ end of erb tag:
<%= robots_tag -%>
just out of interest, why want rid of newline? if in body wouldn't impact result (visible user @ least); in head seems less important.
ruby-on-rails ruby
Comments
Post a Comment