Search code examples
sasshamlpartials

Include Haml External Files Into a Main One


I am trying to include some .haml external files into a main .haml file, like you would do by using SCSS. I tried a numerous of ways to do it, but without no success.

I need to mention that i use Sublime Text 3.

  • header.haml --> partial file that i want to include into main.haml

In main.haml i added:

    // in main.haml:

    !!! 5
    = render 'header'

    ---------------------------------

    !!! 5
    = render partial:'header.haml'

    ---------------------------------

    !!! 5
    = render :partial => 'header.html.haml'

    ---------------------------------

    !!! 5
    = render 'header'

    ---------------------------------

None of these solutions work. Can you help me to include external HAML files into a main one?

Thank you.


Solution

  • I found the solution:

        = Haml::Engine.new(File.read("header.haml")).render
    

    This is what you need to add on every haml page, on which you want to include other haml external pages. Make sure you use the proper indentation, otherwise will not work.

    Have a nice day!