Just landed on a Rails 3 app that uses haml. I am running Rspec tests and trying to print a value of a variable to console. On erb or in a any .rb file, you simply do:
p my_variable.inspect or even string interpolation:
p "this is my variable #{my_variable}" So when I run my Rspec tests I get a nice printout on the console evaluating my variables. So now, how you do that in Haml?
it's so annoying to "p" variables as for me, and then search their output. Use better https://github.com/rweng/pry-rails and then in view just put
- binding.pry
and then in console you can debug variables and other stuff :)
So in Haml just use:
- p my_variable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With