2014-09-25 9 views
0

최근 우리 프로젝트에서 대부분의 뷰 파일을 ERB의 HAML로 이전하려고합니다. 오늘 나는 알아낼 수없는 문제를 썼다. HAML 친자 태그에있는 닫기 태그

_header.html.haml 

%section.page 
.wrapper 

만에

지수와 쇼 파일을 우리는이 같은 부분이 헤더 렌더링 : 우리의 헤더 파일에서이

-- _header.html.haml 
    -- index.html.haml 
    -- show.html.haml 

우리가 예를 들어 태그의 일부를 엽니 다 같이

나는 파일 구조를 가지고

index.html.haml 

= render "layouts/structure/faq_header" 

%section.noborder{ id: "fp-1" } 
    %h2{id: "c1"}= @question_group.title 

HAML을 HTML로 컴파일하면 모든 태그가 _header.html.haml 파일에서 닫힙니다.

<section class="page"> 
    <div class="wrapper"> 
    <section class="noborder" id="fp-1"> 
     <h2 id="c1"> 
     <%= @question_group.title %> 
     </h2> 
    </section> 
    </div> 
</section> 

하지이 좋아 :

<section class="page"> 
     <div class="wrapper"> 
     </div> 
    </section> 
    <section class="noborder" id="fp-1"> 
    <h2 id="c1"> 
     <%= @question_group.title %> 
    </h2> 
    </section> 
말,하지만 난 최종 결과는 같을 것이다, 그래서 어떤 해결 방법이 있습니다하지 않을 경우, 그것은 가능하다조차, 그들 만의 부모 파일에 닫아야합니다

답변

2
당신은 레이아웃으로 헤더 파일을 사용할 필요가

:

# _header.html.haml 
%section.page 
.wrapper 
    = yield 


#index.html.haml 

= render layout: "_header" do 
    %section.noborder{ id: "fp-1" } 
    %h2{id: "c1"}= @question_group.title 
+0

가 속임수를 썼는지 주셔서 감사합니다;) – user2945241