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

一世执手 提交于 2019-11-30 06:47:09

Try the following:

Haml::Template.options[:attr_wrapper] = '"'

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!