使用Rails 3和Haml 3,如何配置Haml? [英] Using Rails 3 and Haml 3, how do I configure Haml?

查看:70
本文介绍了使用Rails 3和Haml 3,如何配置Haml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rails 3.0.0.beta3和Haml 3.0.0.rc.2,但找不到适合放置Haml的配置行的地方(也不知道它们在新版本中的用途)那个问题).使用Rails 2.3.5和Haml 2,我会做到

I'm using Rails 3.0.0.beta3 and Haml 3.0.0.rc.2, and I can't find where I need to place the configuration lines for Haml (nor what they are in the new version, for that matter). Using Rails 2.3.5 and Haml 2, I would do

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

在environment.rb中.或者,在Sinatra中,

in environment.rb. Or, in Sinatra,

set :haml, {:format => :html5}

在我的主文件中.但是在Rails 3中,一切都发生了变化,无论我把配置行放在哪里,都会得到未定义的方法或未定义的对象错误.

in my main file. But in Rails 3 everything's been changed around, and no matter where I put that configuration line, I get an undefined method or undefined object error.

推荐答案

创建文件:

#{Rails.root}/config/initializers/haml.rb

带有haml选项:

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

这篇关于使用Rails 3和Haml 3,如何配置Haml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆