Troy
Troy

Reputation: 1639

Including a plain HTML partial in middleman

I am using middleman with the middleman-slim package to generate a static website. If I have a partial in a file named _test.erb or _test.slim, I can simply include it with the line

== partial 'layouts/test'

However, if this is just a plain .html file, it doesn't work. I've searched around with relatively little success. The options I can think of so far are:

  1. Rename the files to .erb, which will work but I'd rather not.
  2. Include the contents of the file using IO.read (e.g. ==IO.read('source/layouts/_test.html')), which is also ugly

Is there a way I can register a handler for plain .html files to make this work in a simple way?

Upvotes: 2

Views: 858

Answers (1)

This is currently an open issue with Middleman: https://github.com/middleman/middleman/issues/1206

Check the link for up do date info and a couple of workarounds.

My personal approach would be to create a simple helper for IO.read or sprockets.find_asset.

UPD: Thomas Reynolds has fixed this for you! Wait for Middleman 3.3.4 to be released or use it from Github via Bundler:

gem 'middleman', :git => '[email protected]:middleman/middleman.git', :branch => 'v3-stable'

Upvotes: 2

Related Questions