Ruby on Rails Wednesday, June 27, 2018


On Tuesday, June 26, 2018 at 6:06:37 PM UTC+1, David Gautier wrote:
I like ruby and I don't really link ERB templates ...


Why do we (Rails coders) write views as templates using ERB ... ?
Is it a go idea to write views using pure ruby ?



I'm not a massive fan of ERB, however it's not a bad default. Front end developers that are not rubyists can mostly understand it (even if they don't understand the ruby bits they can still work on the markup). I'm also guaranteed that anyone I bring on to the team will understand it.

I don't think of rubocop, code coverage as issues, because I would usually not have enough ruby in the view to make it worthwhile.

Personally I like haml - I find

content_tag(:div, class: "key-value"){ 
   concat content_tag(:span, class: "key"){ key } 
   concat content_tag(:span, class: "value"){ value } 
}

has a lot of noise compared to

.key-value
  %span.key
    key
  %span.value
    value


Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5b87fb71-eefa-4eb0-b2ef-f87e99aca3ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment