I’ve noticed that Haml supports quite a few logic functions (if statements, etc)
I’m curious,
Is it better practice to keep most / all of your programming logic in the Sinatra app.rb or to bleed over into the Haml template.
I don’t want to maintain code in multiple places so I’m assuming to keep it all in whatevert.rb. But I am rather new to sinatra and Haml and open to suggestions and input.
Thanks!
Keep view logic as simple as possible. Looping is just about unavoidable, as are methods that return data you need to display. Beyond that though, it’s best to write some “helper” methods that are exposed to the view to handle advanced logic.
If you post a view that has more logic than you are comfortable with, then perhaps we can advise on how to refactor that. But without any code to review, only general guidelines can be given.