How do I get Haml to work with Rails?

后端 未结 10 1094
一向
一向 2020-12-07 13:15

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

相关标签:
10条回答
  • 2020-12-07 13:42

    First, install haml as a gem in bundler by adding this to your Gemfile:

    gem "haml"
    

    Run bundle install, then make sure your views are named with a *.html.haml extension. For example:

    `-- app
        `-- views
            |-- layouts
            |   `-- application.html.haml
            `-- users
                |-- edit.html.haml
                |-- index.html.haml
                |-- new.html.haml
                `-- show.html.haml
    
    0 讨论(0)
  • 2020-12-07 13:44

    Add haml to your Gemfile:

    gem "haml"
    

    If you want to use the scaffold-functions too, add haml-rails within your development-group:

    gem 'haml-rails', :group => :development
    

    Don't forget to run:

    $ bundle install
    
    0 讨论(0)
  • 2020-12-07 13:49

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

    Just:

    $ cd awesome-rails-3-app.git
    $ echo 'gem "haml"' >> Gemfile
    

    And you're done.

    0 讨论(0)
  • 2020-12-07 13:49

    First, make sure you have the HAML gem.

    gem list --local | grep haml
    

    If haml doesn't show up in the list, then do this:

    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.

    0 讨论(0)
提交回复
热议问题