Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7539089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:17:30+00:00 2026-05-30T07:17:30+00:00

I’m using middleman to do some rapid prototyping and can’t for the life of

  • 0

I’m using middleman to do some rapid prototyping and can’t for the life of me figure out how to include one HAML file into another HAML file.

I can include stuff in a layout file, but can’t get one non-layout file to include another non-layout file. There are blocks of HTML that I want to reuse on some pages and I think I could do this. I’ve tried:

- render: partial=>"shared/nav.haml"
=shared/nav.html
="shared/nav.html

and none of these work.

Am I missing a config option or plugin? This is a fresh middleman install.


ANSWER

Partials may need file names that start with an underscore. My partial is placed in a folder called shared. The full name of the file is _nav.html.haml

This worked for me.

!= haml :"shared/_nav"

Example in context:

#email.main.subscriber.resize
  #bg-wrap
    %div
      %img{:src=>"images/backgrounds/image.png",:alt=>""}
  %section#zone10
    != haml :"shared/_nav"

You may also use the format specified in the approved answer below.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:17:31+00:00Added an answer on May 30, 2026 at 7:17 am

    I’ve been using HAML with MiddleMan and couldn’t be happier. Here is what is working for me:

    I have a file: source/_donate_buttons.h

     #DonationButtons
       %p= t('searching.donate_cover_costs')
       %br
       = partial(:paypal_donate_button, :locals => {:amount => 1, 
         :amount_text => t('searching.donate_1')})
    

    This uses the partial statement shown to include a file called source/_paypal_donate_button.html.haml.

    And I include the _donate_buttons.html.haml file itself in a couple of places with:

    = partial "donate_buttons"
    

    though I think this could also be:

    = partial :donate_buttons
    

    I.e. I think partial is the magic you’re looking for.

    And, just for completeness, here is a slightly stripped down _paypal_donate_button.haml which shows how the paramaterization works there:

    -btnclass = (locals.key?(:highlight) && locals[:highlight] ? "HighlightedDonationButton" : "DonationButton")
    -btnstyle = locals.key?(:button_style) && locals[:button_style]
    .DonationButtonContainer
      %form{:action => "https://www.paypal.com/cgi-bin/webscr", :method => "post"}
        %input{:name => "business", :type => "hidden", :value => "payments@example.com"}
        %input{:name => "cmd", :type => "hidden", :value => "_donations"}
        %input{:name => "amount", :type => "hidden", :value => "#{amount}.00"}
        %input{:name => "currency_code", :type => "hidden", :value => "USD"}
        %input{:class => btnclass, :alt => t('paypal.alt_text'),
          :style => "cursor: pointer; font-size: 18px; #{btnstyle}", :type => "submit", :value => amount_text}
    

    Fwiw, I don’t think the file needs to be _filename.html.haml and can instead be _filename.haml. Also, I’m localizing these, so ignore the t(‘tagname’) and just put strings there. (I didn’t want to introduce an error copy-pasting the examples so I left them in there.)

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.