asciidoctor / asciidoctor-backends

Backends (i.e., templates) for Asciidoctor, a Ruby port of AsciiDoc.
http://asciidoctor.org
Other
65 stars 73 forks source link

Fix slim/html5/section – use :sectnumlevels attribute #82

Closed jirutka closed 10 years ago

jirutka commented 10 years ago

It’s just copied it from HAML template for now, I’ll rewrite it using helper method after merging asciidoctor#1143.

mojavelinux commented 10 years ago

Nice!

For reference, I tend to write method calls in a Clojure-style where reasonable. This makes them more consistent with places where brackets are not needed. In this particular case:

(@document.attr 'sectnumlevels', 3).to_i

instead of

@document.attr('sectnumlevels', 3).to_i

I'll update after the merge.

mojavelinux commented 10 years ago

(Admittedly, I haven't been perfectly consistent about the style, but I'd like to try to get there).

jirutka commented 10 years ago

To be honest, I’ve noticed that, but I consider it a bad practice – it’s not idiomatic for Ruby (Ruby is not a Lisp dialect!) and it’s against de-facto standard Ruby style guide.

mojavelinux commented 10 years ago

and it’s against de-facto standard Ruby style guide.

What can I say, I'm a rebel :)

My thinking isn't mainstream, but I view it as more idiomatic than the style guide recommendation. The reason is that Ruby allows brackets to be left out. When they have to be put back in, you can see it two ways. You can either see it as the brackets identify the boundaries of the expression or the brackets have to be used in the more traditional way around method arguments. I like how the brackets show the boundaries of the expression. I may lose this debate in the end, but to me it reads a lot better this way.