I am trying to get Haml to work with my Ruby on Rails project. I am new to Ruby on Rails and I really like it. However, when I attempt to add an aplication.html.haml
or index.html.haml
for a view, I just receive errors.
我正试图让Haml与我的Ruby on Rails项目一起工作。我是Ruby on Rails的新手,我非常喜欢它。但是,当我尝试添加一个api .html时。haml或index . html。haml为视图,我只接收错误。
I am using NetBeans as my IDE.
我正在使用NetBeans作为我的IDE。
9 个解决方案
#1
88
Haml with Rails 3
For Rails 3 all you need to do is add gem "haml", '3.0.25'
to your Gemfile
. No need to install plugin or run haml --rails .
.
对于Rails 3,您所需要做的就是将gem“haml”、“3.0.25”添加到Gemfile中。无需安装插件或运行haml -rails。
Just:
只是:
$ cd awesome-rails-3-app.git $ echo 'gem "haml"' >> Gemfile
And you're done.
你就完成了。
#2
59
The answers above are spot-on. You just need to put gem 'haml'
in your Gemfile
.
上面的答案是正确的。你只需要在你的宝石文件中加入宝石“haml”。
One other tip that was not mentioned: to have rails generators use haml
instead of erb
, add the following to config/application.rb
:
另一个没有提到的技巧是:要让rails生成器使用haml而不是erb,请在config/application.rb中添加以下内容:
config.generators do |g|
g.template_engine :haml
# you can also specify a different test framework or ORM here
# g.test_framework :rspec
# g.orm :mongoid
end
#3
37
First, install haml as a gem in bundler by adding this to your Gemfile
:
首先,在bundler中将haml作为gem安装到Gemfile中:
gem "haml"
Run bundle install
, then make sure your views are named with a *.html.haml extension. For example:
运行bundle install,然后确保您的视图使用*.html命名。haml扩展。例如:
`-- app
`-- views
|-- layouts
| `-- application.html.haml
`-- users
|-- edit.html.haml
|-- index.html.haml
|-- new.html.haml
`-- show.html.haml
#4
24
Add haml to your Gemfile:
将haml添加到您的Gemfile:
gem "haml"
If you want to use the scaffold-functions too, add haml-rails within your development-group:
如果您也想使用脚手架功能,请在开发团队中添加haml-rails:
gem 'haml-rails', :group => :development
Don't forget to run:
别忘了运行:
$ bundle install
#5
11
Before trying to use haml in your rails application, you can verify that the command line executable is installed correctly:
在尝试在您的rails应用程序中使用haml之前,您可以验证命令行可执行文件是否安装正确:
$ haml
%p
%span Hello World!
Then press CTRL-D and you should see:
然后按CTRL-D,你会看到:
<p>
<span>Hello World!</span>
</p>
#6
10
First, make sure you have the HAML gem.
首先,确保你有HAML宝石。
gem list --local | grep haml
If haml doesn't show up in the list, then do this:
如果haml没有出现在列表中,那么这样做:
sudo gem install haml
Then do this from your project directory:
然后从你的项目目录中:
# cd ../
# haml --rails <yourproject>
That should install everything you need, and the HAML views should stop complaining and parse correctly.
应该安装所有需要的东西,HAML视图应该停止抱怨并正确解析。
#7
3
This may be an old question but I think the answer is using haml-rails at https://github.com/indirect/haml-rails
这可能是一个老问题,但我认为答案是在https://github.com/indirect/haml-rails上使用haml-rails
#8
1
if for some reason you installed haml, but you haml doesn't start. try
如果因为某种原因你安装了haml,但是haml没有启动。试一试
sudo ln haml /usr/bin/
in the bin directory of your haml gem
在你的haml gem的bin目录中
for some reason this didn't happen automatically on my ubuntu 9.04 Jaunty.
出于某种原因,这在我的ubuntu 9.04 Jaunty上并没有自动发生。
#9
#1
88
Haml with Rails 3
For Rails 3 all you need to do is add gem "haml", '3.0.25'
to your Gemfile
. No need to install plugin or run haml --rails .
.
对于Rails 3,您所需要做的就是将gem“haml”、“3.0.25”添加到Gemfile中。无需安装插件或运行haml -rails。
Just:
只是:
$ cd awesome-rails-3-app.git $ echo 'gem "haml"' >> Gemfile
And you're done.
你就完成了。
#2
59
The answers above are spot-on. You just need to put gem 'haml'
in your Gemfile
.
上面的答案是正确的。你只需要在你的宝石文件中加入宝石“haml”。
One other tip that was not mentioned: to have rails generators use haml
instead of erb
, add the following to config/application.rb
:
另一个没有提到的技巧是:要让rails生成器使用haml而不是erb,请在config/application.rb中添加以下内容:
config.generators do |g|
g.template_engine :haml
# you can also specify a different test framework or ORM here
# g.test_framework :rspec
# g.orm :mongoid
end
#3
37
First, install haml as a gem in bundler by adding this to your Gemfile
:
首先,在bundler中将haml作为gem安装到Gemfile中:
gem "haml"
Run bundle install
, then make sure your views are named with a *.html.haml extension. For example:
运行bundle install,然后确保您的视图使用*.html命名。haml扩展。例如:
`-- app
`-- views
|-- layouts
| `-- application.html.haml
`-- users
|-- edit.html.haml
|-- index.html.haml
|-- new.html.haml
`-- show.html.haml
#4
24
Add haml to your Gemfile:
将haml添加到您的Gemfile:
gem "haml"
If you want to use the scaffold-functions too, add haml-rails within your development-group:
如果您也想使用脚手架功能,请在开发团队中添加haml-rails:
gem 'haml-rails', :group => :development
Don't forget to run:
别忘了运行:
$ bundle install
#5
11
Before trying to use haml in your rails application, you can verify that the command line executable is installed correctly:
在尝试在您的rails应用程序中使用haml之前,您可以验证命令行可执行文件是否安装正确:
$ haml
%p
%span Hello World!
Then press CTRL-D and you should see:
然后按CTRL-D,你会看到:
<p>
<span>Hello World!</span>
</p>
#6
10
First, make sure you have the HAML gem.
首先,确保你有HAML宝石。
gem list --local | grep haml
If haml doesn't show up in the list, then do this:
如果haml没有出现在列表中,那么这样做:
sudo gem install haml
Then do this from your project directory:
然后从你的项目目录中:
# cd ../
# haml --rails <yourproject>
That should install everything you need, and the HAML views should stop complaining and parse correctly.
应该安装所有需要的东西,HAML视图应该停止抱怨并正确解析。
#7
3
This may be an old question but I think the answer is using haml-rails at https://github.com/indirect/haml-rails
这可能是一个老问题,但我认为答案是在https://github.com/indirect/haml-rails上使用haml-rails
#8
1
if for some reason you installed haml, but you haml doesn't start. try
如果因为某种原因你安装了haml,但是haml没有启动。试一试
sudo ln haml /usr/bin/
in the bin directory of your haml gem
在你的haml gem的bin目录中
for some reason this didn't happen automatically on my ubuntu 9.04 Jaunty.
出于某种原因,这在我的ubuntu 9.04 Jaunty上并没有自动发生。