Multiple multi-line HAML blocks

后端 未结 4 1830
野的像风
野的像风 2021-01-01 15:43

Using the (intentionally) strange multi-line format for HAML, I\'d like to have the following lines in my template:

= call_to_helper :foo1 => \'bar1\', :f         


        
4条回答
  •  遥遥无期
    2021-01-01 16:25

    I've encountered the same problems and workarounds as have been mentioned here, and the weird (and yes, it IS weird) behavior of HAML with regard to multi-line blocks has bitten me quite a few times. I know that it's intentional and that it was probably intended to force the user to make his code easier to read. However, it's a well known fact that every developer has his own preferences when it comes to structuring code. HAML is the only language I know of (c, c++, ruby, python, HTML, etc.) that tries to impose such restrictions.

    Calling the weird multi-line handling a feature rather than a bug, just indicates a flawed language design. In the end it will always be a bug in the eyes of the user. Multi-line support is a basic feature of any main stream language and the lack of this feature is just plain annoing - just like the M$ paperclip, which I believe was also an attempt to guide the user.

    That being said, HAML is a fantastically compact and useful language for writing HTML. Those of us who (in some cases) prefer multi-line blocks would just love to at least be offered some kind of configuration option to enable/disable decent multi line block support - regardless of the language designer's personal definition of "easy to read code".

    Until we get there, I guess we'll have to work around the language using the "-#" hack...

提交回复
热议问题