1

Example template:

%input{ @attributes }

Example rendering:

@attributes = {:foo => :bar}
render :example_template 

Example output with haml:

<input foo="bar">

I tried to achieve this with haml-coffe with JST['example_template']({attributes: {foo: 'bar'}} but it doesn't seem to work like I expected.

How one can give all attributes completely dynamically with haml-coffee?

Joni
  • 3,327
  • 3
  • 25
  • 22

1 Answers1

2

Specify all attributes by giving an object is not supported in Haml-Coffee, you need to explicitly define all attribute known at compile time:

%input{ foo: @attributes['bar'] }

and render the template with

JST['example_template'](attributes: { foo: 'bar' })

If you need to define all attributes freely, then I suggest you to set it in your view, e.g.

class ExampleView extends Marionette.View

  ui:
    foo: 'input[foo]'

  onRender: ->
    @ui.foo.attr(@attributes)
Netzpirat
  • 5,481
  • 1
  • 22
  • 21