Haml - how do I force tag attributes to use double quotes only AND how do I order tag attributes the way I want?

前端 未结 3 1263
名媛妹妹
名媛妹妹 2020-12-30 02:37

I use staticmatic for templates I use later with PHP. There is an odd situation where some tag attributes have single quotes, while some have double quotation marks. I would

相关标签:
3条回答
  • 2020-12-30 02:58

    Quote from: http://haml.info/docs/yardoc/file.REFERENCE.html#options

    Haml understands various configuration options that affect its performance and output.

    In Rails, options can be set by setting the Haml::Template.options hash in an initializer:

    # config/initializers/haml.rb

    Haml::Template.options[:format] = :html5
    

    Outside Rails, you can set them by configuring them globally in Haml::Options.defaults:

    Haml::Options.defaults[:format] = :html5
    

    Finally, you can also set them by passing an options hash to [Haml::Engine#initialize][1]. For the complete list of available options, please see [Haml::Options][2].

    [1]: http://haml.info/docs/yardoc/Haml/Engine.html#initialize-instance_method

    [2]: http://haml.info/docs/yardoc/Haml/Options.html

    0 讨论(0)
  • 2020-12-30 03:08

    Try the following:

    Haml::Template.options[:attr_wrapper] = '"'
    
    0 讨论(0)
  • 2020-12-30 03:22

    Haml does indeed order attributes alphabetically, and this is indeed a consequence of Ruby's parser. In the future, attributes may be ordered in document order as much as possible, but that's not likely to happen until Haml 2.2 or later.

    0 讨论(0)
提交回复
热议问题