[RUBY] [Rails] How to convert from erb to haml

What is haml?

Haml is an abbreviation for HTML Abstraction Markup Language. A markup language for generating html (which can also generate xml). Since the amount of description is smaller than that of html and indentation is forced, it is possible to create it very neatly and concisely.

manner

gemfile


gem 'haml-rails'

Terminal


$ bundle install

Terminal


$ rails haml:erb2haml

Terminal


Would you like to delete the original .erb files? (This is not recommended unless you are under version control.) (y/n)

Is it okay to delete the conversion source .erb file? Is asked, so press y → enter here to complete.

Summary

I've been writing code in erb for a long time, and I was impressed that the amount of description was significantly reduced and it became easier to see just by changing to haml. However, when I looked it up, it seems that there are people who are difficult for engineers to do, such as the difference in performance between haml and erb, grammar, whether it is the default, etc. That looks good.

That was a memorandum.

Recommended Posts

[Rails] How to convert from erb to haml
How to convert erb file to haml
How to change from HTML to Haml
How to convert param to hash with Rails controller (updated from time to time)
How to write Rails
How to uninstall Rails
[Ruby] How to convert from lowercase to uppercase and from uppercase to lowercase
How to link Rails6 Vue (from environment construction)
[Rails] How to convert UC time display to Japanese time display
[rails] How to post images
[Rails] How to use enum
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
How to use rails join
[How to insert a video in haml with Rails]
Convert from ○ months to ○ years ○ months
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
How to download images from AWS S3 (rails, carrierwave)
[Rails] How to disable turbolinks
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
How to convert Java radix
[Rails] How to implement scraping
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
How to migrate from JUnit4 to JUnit5
[Rails] How to use Scope
How to write a migration from Rails datetime type to date type
[Java] How to convert a character string from String type to byte type
[Rails 5] How to use gem gon ~ How to pass variables from Rails to JS ~
[Rails] How to use gem "devise"
How to deploy jQuery on Rails
How to push from Tarminal to GitHub
[Rails] How to use devise (Note)
[Rails] How to use flash messages
[rails] How to display db information
[Rails] How to write in Japanese
[Rails] How to prevent screen transition
How to use Ruby on Rails
How to deploy Bootstrap on Rails
[Rails] How to speed up docker-compose
[Rails] How to add new pages
How to convert LocalDate and Timestamp
Rails on Tiles (how to write)
[Rails] How to write exception handling?
[Rails] How to install ImageMagick (RMajick)
[Rails] How to install Font Awesome
[Rails] How to use Active Storage
How to introduce jQuery in Rails 6
[Rails] How to implement star rating
How to return Rails API mode to Rails
How to get along with Rails
[Introduction to Rails] How to use render
How to install Swiper in Rails
How to prevent past dates from being entered in Rails forms