vendredi 22 mars 2019

Correct format for writing conditionals in ruby and then converting output into string using string interpolation inside HAML tag

I am fixing a bug in a ruby on rails open source project at the front end of the project. I am a newbie to ruby on rails, HAML etc. The following line of code is giving me a lot of trouble.

I am wondering what would be correct way to format this. Further, is there a way to write a helper function to turn the conditionals into a function call? Any help will be appreciated.

I have tried several formats but the devs want me to break up the if-else into several lines. I am unable to make that work.

%strong 
= "#{"producer " 
- if @enterprise.is_primary_producer
  = t('.producer_profile')
- else
  = t('.profile')
  }profile"


I expect the view to be rendered but instead I get syntax errors.

Aucun commentaire:

Enregistrer un commentaire