2

I am currently using Yeoman with HAML (utilising grunt-contrib-haml) and would like to include HAML files to make things more DRY.

I am not that familiar with HAML, so after reading online it appears best to use =render, like so:

=render(partial="shared/ga")

however I am receiving the message that HAML lacks a native render() function:

Warning: Exception on line 75: undefined method `render' for #<Object:0x00000003474a98>

Is there a simple way to include HAML files from inside another HAML file, which will work with Yeoman/grunt-contrib-haml? and/or extending an existing HAML template to make things more DRY?

Metalshark
  • 8,194
  • 7
  • 34
  • 49
  • 2
    Switched to Jade (which makes this trivial) in the end and haven't looked back. – Metalshark Jan 23 '14 at 20:34
  • render is a Rails feature, not a HAML one. See: http://stackoverflow.com/questions/6125265/using-layouts-in-haml-files-independently-of-rails – jhchen Mar 04 '14 at 21:08

1 Answers1

1

I had the same issue. I found that the simplest approach to this issue is to use js to import the files instead of the haml method. I'm using Angular.js so I can use it's imports and skip HAML's.

In the HAML template you write something like this (for Angular):

%div#publish{ng-include: 'views.someview', ng-controller: 'SomeCtrl'}

Works like a charm.

clopez
  • 4,372
  • 3
  • 28
  • 42