Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional content in html.erb

i have a footer as the last element in my application.html.erb page, however for one page in the whole site, i do not want the footer to appear.

Whats the best way to handle this? every solution i come up with is wet (not dry)

like image 543
pingu Avatar asked Dec 30 '25 13:12

pingu


1 Answers

Why don't you create a specific layout for this single page? It should be more maintainable than any extra logic.

DRY is not a goal to reach, it's like a conditional warning and like all warnings, you can ignore them if it makes sense.


If you really insist, do this:

<% unless defined? @no_footer %>
  your html here
<% end %>

So the footer will disappear only if you set the instance variable in your controller:

@no_footer = true

Another way could be to check params action/controller and put the logic in a helper method.

like image 61
apneadiving Avatar answered Jan 02 '26 08:01

apneadiving