6 ms·
.col-md-8 #{@record.name} / #{@record.description} - binding.pry = check_box_tag(display, true, @record.display, :disabled => true)
by csense 10y ago
.col-md-8
#{@record.name} / #{@record.description}
- binding.pry
= check_box_tag(display, true, @record.display, :disabled => true)
= _('Display in Catalog')
Ruby syntax is terrifying. There is so much going on here I can't even begin to figure out what this code is supposed to do.
- d4l3k 10y agoThat's less the fault of Ruby and more the fault of HAML. http://haml.info/ http://haml.info/
- psadauskas 10y agoThis is 90% HAML syntax, and not even very good HAML; the first line (`.col-md-8`) is even worse because of Bootstrap. The only real Ruby is on Line 4. I don't even know what Line 5 is trying to do. Don't let this poor example turn you off from Ruby, its syntax is amazing. One of my biggest struggles with using other languages is just how ugly the syntax is, even in the best case.
- pauldino 10y agoLine 5 looks like it's for i18n. To save on typing and reduce clutter typically "_" is used as an alias for the gettext function.
- psadauskas 10y agoAh, that makes sense. Thanks.
- weaksauce 10y agoLike others have said, that's mostly HAML. HAML syntax is actually succinct and nice once you know what the codes mean. Basics of it: indentation nests html elements. each line is basically an element or a control structure. = is run this ruby code and display it. - is run this ruby code but don't display it. a period with something after it is shorthand for create a div with that as a class. the fact that it creates nicely formatted html that is automatically closed for you is a bonus. the #{} part is string interpolation that comes from ruby and those items inside that are just ruby objects with functions/attributes on them. Give ruby a chance and you will likely fall in love with the syntax.