由于我遇到的 Javascript 框架问题,我需要在属性上使用双引号,并且我已尝试按照文档在使用 Rails 时的建议设置 Haml::Template.options 哈希,但对 ' 没有影响assets' 文件夹,无论我在哪里设置选项。请注意,它正在处理由 Rails 控制器呈现的普通 ActionView 模板,但不在我拥有的模板中{Rails.root}/app/assets/javascripts/templates/*.html.haml
这就是我所拥有的{Rails.root}/config/initializers/haml.rb
:
Haml::Template.options[:attr_wrapper] = '"'
# Adds the ability to use HAML templates in the asset pipeline for use with
# Batman.js partials
Rails.application.assets.register_mime_type 'text/html', '.html'
Rails.application.assets.register_engine '.haml', Tilt::HamlTemplate
我也尝试过更改register_engine
使用Haml::Engine
and Haml::Template
,它们都可以渲染,但仍然没有采用我在上面设置的选项。
如何设置 Haml 选项以在资产管道中进行渲染?似乎我需要传递 Sprocket 引擎的选项?