Custom rendering for handlebars

I have to reuse some given handlebars-templates in my middleman-project. So my plan would be to call a .hbs-partial, instead of haml-partials, like i did in rest of project.

I think, what i need is smth like this: https://gist.github.com/audionerd/2026206

I adapted this for handlebars and updated my gemfile accordingly:

gem 'handlebars'
gem 'tilt-handlebars'

As I am not that used with ruby, I have no idea where to put the module-code. Tried to call it from config.rb like this:

require 'helpers/handlebars_helper'
helpers Handlebars

But this does not work, so i think this is the wrong way…

Can somebody help me out here how to include this into my project?

Thanks!

Actually I was probably searching too wide. Just including the Gems seems to load the partial correctly.
Sadly, this is a partial, which was made with the npm handlebars-helpers, which are not available as rubygem, so i have to find another solution for that one.

Are you trying to use Handlebars lang instead of ERB or Haml?

If you are just trying to use Handlebars in javascript, you can try the handlebars_assets gem, which works well for me in ruby projects, incl. Middleman.

Then in your config.rb you just need:

require 'handlebars_assets'

ready do
   sprockets.append_path HandlebarsAssets.path
end

and you’ll be able to use handlebars templates in your JS out of the box. See the gem readme for more info.

I’ll try actually to use handlebars together with haml. So i have a HAML-view and like to include a handlebars-partial. Actually, this works now for me, but not with the according handlebars-helpers from assemble.

I know, complicated case, but i have to mix up a middleman-project with a gulp-project, i think this won’t work, so I have somehow to duplicate those views and convert the handlebars to haml.