haml - 通过.haml文件传递变量

时间:2016-09-05 22:34:34

标签: haml

我有view.hamlpartial.haml我想要处理的是,在view.haml中声明一个变量,但在渲染后将其打印在partial.haml中,我不使用rails或synatra或aany框架,这只是haml,我该怎么做?

view.haml代码:

-  test = 'Hello world'
!!! 5
%html{:lang => "es"}
  %head
  %body
    / Breadcrumbs
    = Haml::Engine.new(File.read(File.expand_path 'src/views/components/breadcrumbs.haml', File.dirname(__FILE__))).render

partial.haml

%section.Breadcrumbs
   %h2.Breadcrumbs-title Title
   %ul.Breadcrumbs-links
     %li
       %a{:href => "#"}
          #{test}
     %li
        %a{:href => "#"} Bread 2
     %li.active Bread 3

0 个答案:

没有答案