如何启动使用 HAML 和 SASS 作为默认模板的 Rails 3 应用程序?
线路
rails new someapp -m haml
不工作。似乎需要一条通往某个地方的路径。
更新: haml-rails
实际上是由 gem install haml-rails
安装的,但上面的行不起作用。
the line
rails new someapp -m haml
doesn't work. It seems to need a path to some where.
Update: haml-rails
is in fact installed by gem install haml-rails
but the line above wouldn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
非常简短的版本
基于一个简单的模板生成一个新的 Rails 应用程序,该模板设置了开箱即用的 Haml(以及其他一些不错的可选功能)。
http://decielo.com/articles/377/ haml-by-default-in-a-new-rails-3-2-app
另请查看:
https: //github.com/RailsApps/rails-composer
编辑:
如果您想通过“gem”执行此操作,您只需运行默认命令
rails new myapp -m https://raw。 github.com/RailsApps/rails-composer/master/composer.rb
这是一个安全的命令,因为它指向 gem 的 master 分支,并且将是一个稳定的 URL。运行此命令后,系统将提示您提供选项。当向导询问时,只需选择 HAML 和 SASS 即可。
The really short version
Generate a new rails app based on a simple template that sets up Haml out of the box (and some other nice optional features).
http://decielo.com/articles/377/haml-by-default-in-a-new-rails-3-2-app
Also check this out:
https://github.com/RailsApps/rails-composer
EDIT:
If you want to do this through the "gem" you simply need to run the default command
rails new myapp -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
This is a safe command as it points to the master branch of the gem and will be a stable URL. Once you have run this command you will be prompted with options. Simply select HAML and SASS when asked by the wizard.
Gem
haml-rails
允许在 Haml 中生成视图,但不能生成初始布局。运行
rails new someapp
(注意:w/o-m haml
)并将行gem "haml-rails"
添加到您的后Gemfile
,只需将application.html.erb
重命名为application.html.haml
,并手动将其内容从ERB转换为Haml即可。之后,所有生成的视图都将位于 Haml 中。
Gem
haml-rails
allows to generate views in Haml, but not the initial layout.After running
rails new someapp
(note: w/o-m haml
) and adding linegem "haml-rails"
to yourGemfile
, you just need to renameapplication.html.erb
toapplication.html.haml
and manually convert its content from ERB to Haml.After that, all generated views will be in Haml.
应用程序/视图/布局/application.html.haml
app/views/layouts/application.html.haml
确保您安装了
haml-rails
gem。Make sure you have the
haml-rails
gem installed.不要忘记将
gem 'haml-rails'
添加到您的 Gemfile 中。Don't forget to add
gem 'haml-rails'
to your Gemfile.很简单,但请确保在添加 haml gems 并运行
bundle install
后重新启动 Rails 服务器。这让我第一次。Trivial, but make sure you restart your rails server after adding the haml gems and run
bundle install
. This got me the first time around.安装 gem html2haml,您可以立即从 vim 中将 html 内容更改为 haml。看看这个 - http: //www.economyofeffort.com/2014/07/20/convert-html-to-haml-within-vim-buffer/
Install the gem html2haml and you can instantly change the html content to haml from within vim. Have a look at this - http://www.economyofeffort.com/2014/07/20/convert-html-to-haml-within-vim-buffer/