首页 > 解决方案 > 在没有 Rails 的情况下使用 HAML,如何在部分下嵌套元素?

问题描述

我正在使用 HAML,没有导轨。我希望能够使用部分,但在部分下嵌套项目。这可能吗?每次我尝试时,我都会收到一条错误消息:Errno::ENOENT: No such file or directory @ rb_sysopen. 这是我正在尝试的示例:

设置脚本

sudo gem install haml

应用程序.rb

def RENDER_COMPONENT(display, anchor)
    contents = File.read("component.haml")

    Haml::Engine.new(contents).render
end

组件.haml

.data

父.haml

:ruby
    require_relative "app"

!!!
%html
    %body
        =RENDER_COMPONENT()
            %h1= "Test"
            %H2= "Test"

命令行

haml parent.haml index.html

标签: haml

解决方案


推荐阅读