如何启动使用 HAML 和 SASS 作为默认模板的 Rails 3 应用程序?

发布于 2024-09-17 19:51:31 字数 201 浏览 7 评论 0原文

线路

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

又怨 2024-09-24 19:51:31

非常简短的版本

基于一个简单的模板生成一个新的 Rails 应用程序,该模板设置了开箱即用的 Haml(以及其他一些不错的可选功能)。

rails new ProjectName -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-haml-html5-template.rb

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).

rails new ProjectName -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-haml-html5-template.rb

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.

眉目亦如画i 2024-09-24 19:51:31

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 line gem "haml-rails" to your Gemfile, you just need to rename application.html.erb to application.html.haml and manually convert its content from ERB to Haml.

After that, all generated views will be in Haml.

ら栖息 2024-09-24 19:51:31

应用程序/视图/布局/application.html.haml

!!!
%html
  %head
    %title "HAML'd"
    = stylesheet_link_tag    "application"
    = javascript_include_tag "application"
    = csrf_meta_tags
  %body
    = yield

app/views/layouts/application.html.haml

!!!
%html
  %head
    %title "HAML'd"
    = stylesheet_link_tag    "application"
    = javascript_include_tag "application"
    = csrf_meta_tags
  %body
    = yield
遇见了你 2024-09-24 19:51:31

确保您安装了 haml-rails gem。

Make sure you have the haml-rails gem installed.

梦中的蝴蝶 2024-09-24 19:51:31

不要忘记将 gem 'haml-rails' 添加到您的 Gemfile 中。

Don't forget to add gem 'haml-rails' to your Gemfile.

绳情 2024-09-24 19:51:31

很简单,但请确保在添加 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.

木森分化 2024-09-24 19:51:31

安装 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文