I have a bit of interpolated ruby code in a HAML document that looks like the following:
:javascript
a = { 'something' : "#{model.attribute.present? ? method(parameter) : ''}" }
However, the method(parameter) is throwing exceptions with some parameters, so I would like to rescue the exception. When the exception is thrown, I would like the ‘something’ key to be mapped to something else.
I am not clear on the exact syntax of how to do this with the HAML code/ruby interpolation. I’ve tried a couple things, but it’s not working.
Thanks!
You should take this line
and make a helper method out of it
Then your HAML becomes trivial