Haml syntax: split a line to a couple of rows

benams picture benams · Dec 18, 2012 · Viewed 15.7k times · Source

I use HAML in my rails project for my html templates. I would like to figure out if its possible to divide a very long line and make it a couple of rows:

%a.open-service{href: '#', data: {
  service_name: service.description,
  balance_type: "coinsurance",
  total: service.a_total_billed - service.a_rejected - service.a_not_covered, 
  discount: service} }

As you can see, I just want to have an anchor with href and some data-attributes, and making it one-line won't be a pretty code. But when I do it like above I get an error: "Unbalanced brackets."

any help?

Answer

Paul Fioravanti picture Paul Fioravanti · Dec 18, 2012

New lines can be placed after commas, according to the Haml documentation. So, perhaps something like the following would work:

%a.open-service{href: '#', 
                data: { service_name: service.description,
                        balance_type: "coinsurance",
                        total: service.a_total_billed - service.a_rejected - service.a_not_covered, 
                        discount: service} }