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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -