Structuring of layout template in Haml

一世执手 提交于 2019-12-02 18:11:55
tjwallace

This solution is for Ruby on Rails only:

You can use yield(:location) and the content_for(:location) methods, more information.

layout.haml

!!!
%html
  %head
    %title= yield(:title)
    = yield(:head)
  %body
    = yield

view.haml

- content_for(:title, 'My title')
- content_for(:head) do
  = javascript_include_tag :foo

%h1 My view!

I use partials:

!!!
%html
  = partial('trst_sys/shared/html-head')

  %body{:id => "srv",:'data-lang' => current_lang}
  #main.wrap
    %header#header
      = partial('trst_sys/shared/header')
    %nav#menu
      = partial('trst_sys/shared/menu')
    %section#content
      %article#xhr_content
        = yield
      %article#xhr_msg.hidden
    %section#sidebar
      = partial('trst_sys/shared/sidebar')
    %section#main_footer.wrap
  %footer#footer.wrap
    = partial('trst_sys/shared/footer')
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!