Reputation: 1974
I've got a problem with nesting of html/haml tags in my Rails app. I have default layout for app:
!!!
%html
%head
= render 'shared/head'
%body
= render 'shared/alerts'
= render 'shared/header'
.content
= yield
= render 'shared/footer'
I've got this html:
<html>
<head>..</head>
<body>
<div class="menubar">..</div>
<div class="content">..</div>
<div class="footer">..</div>
</body>
</html>
As you can see footer
is out of the .content
. The problem is footer
is nested to .content
in one view file and I don't know why:
<html>
<head>..</head>
<body>
<div class="menubar">..</div>
<div class="content">
<div class="footer">..</div>
</div>
</body>
</html>
View file where html is breaking
<div id='topic' class='#{'un' unless @topic.locked?}locked'>
\#{render :partial => 'forem/topics/head', :locals => { :topic => @topic }}
.small-offset.up
- if @topic.can_be_replied_to? && can?(:reply, @topic)
= link_to t(".reply"), forem.new_topic_post_path(@topic), class: "button medium rounded lime"
- if @topic.user == forem_user || forem_admin?
= link_to t(".delete"), forem.forum_topic_path(@forum, @topic), method: :delete, data: { confirm: t("are_you_sure") }
- if forem_user
- if [email protected]?(forem_user.id)
= link_to t(".subscribe"), forem.subscribe_forum_topic_path(@forum, @topic), class: "button medium rounded blue"
- else
= link_to t(".unsubscribe"), forem.unsubscribe_forum_topic_path(@forum, @topic), class: "button medium rounded pink"
- if forem_admin?
= link_to t('forem.topic.links.edit'), forem.edit_admin_topic_path(@topic)
= link_to t(".hide.#{@topic.hidden}"), forem.toggle_hide_admin_topic_path(@topic), method: :put
= link_to t(".lock.#{@topic.locked}"), forem.toggle_lock_admin_topic_path(@topic), method: :put
= link_to t(".pin.#{@topic.pinned}"), forem.toggle_pin_admin_topic_path(@topic), method: :put
- if @topic.pending_review?
= t(".pending_review")
- if forem_admin_or_moderator?(@topic.forum)
= form_for @topic, url: forem.moderate_forum_topic_path(@topic.forum, @topic), method: :put do |f|
= render "/forem/moderation/options", f: f
= forem_pages_widget(@posts)
= render partial: "forem/posts/post", collection: @posts
= forem_pages_widget(@posts)
Upvotes: 0
Views: 563
Reputation: 9764
The view where it's breaking is missing a closing div tag, you open the div:
<div id='topic' class='#{'un' unless @topic.locked?}locked'>
but don't close it, try adding </div>
to the end, this should fix it
Or, even better turn the div into haml and then indentention will sort itself out:
#topic{class: @topic.locked? "locked" : "unlocked"}
= render :partial => 'forem/topics/head', :locals => { :topic => @topic }
.small-offset.up
- if @topic.can_be_replied_to? && can?(:reply, @topic)
= link_to t(".reply"), forem.new_topic_post_path(@topic), class: "button medium rounded lime"
- if @topic.user == forem_user || forem_admin?
= link_to t(".delete"), forem.forum_topic_path(@forum, @topic), method: :delete, data: { confirm: t("are_you_sure") }
- if forem_user
- if [email protected]?(forem_user.id)
= link_to t(".subscribe"), forem.subscribe_forum_topic_path(@forum, @topic), class: "button medium rounded blue"
- else
= link_to t(".unsubscribe"), forem.unsubscribe_forum_topic_path(@forum, @topic), class: "button medium rounded pink"
- if forem_admin?
= link_to t('forem.topic.links.edit'), forem.edit_admin_topic_path(@topic)
= link_to t(".hide.#{@topic.hidden}"), forem.toggle_hide_admin_topic_path(@topic), method: :put
= link_to t(".lock.#{@topic.locked}"), forem.toggle_lock_admin_topic_path(@topic), method: :put
= link_to t(".pin.#{@topic.pinned}"), forem.toggle_pin_admin_topic_path(@topic), method: :put
- if @topic.pending_review?
= t(".pending_review")
- if forem_admin_or_moderator?(@topic.forum)
= form_for @topic, url: forem.moderate_forum_topic_path(@topic.forum, @topic), method: :put do |f|
= render "/forem/moderation/options", f: f
= forem_pages_widget(@posts)
= render partial: "forem/posts/post", collection: @posts
= forem_pages_widget(@posts)
Upvotes: 2