HTML: (Paste ERB code below and press Convert to HAML button) |
HAML: |
# How To Use In Your Ruby On Rails Application
HAML (HTML abstraction markup language) is a beautiful and elegant way to describe and design the HTML of your views. Instead of opening- and closing tags, HAML uses indentation for the structure of your pages
Examples:
File #new.html.erb
<h1><%= @page_name %></h1>
<p>This is my form</p>
<%= render "form" %>
And in HAML:
File: #new.html.haml %h1= @the_title
%p This is my form
= render 'form'
You see, the structure of the layout is much clearer than using HTML and ERB.
Installation
First install the gem using
gem install haml
and add the gem to the Gemfile
gem "haml"
For using HAML instead of HTML/ERB, just replace the file extensions of your views from file_name.html.erb to file_name.html.haml.
Quick tipps
Common elements like divs can be written in a short way
HTML
<div class="myclass">Write Content Here</div>
HAML
%div.myclass
HAML, shorthand
.myclass Write Content
Here
Attributes
HTML
<p class="myclass" id="myid">My paragraph</p>
HAML
%p{:class => "myclass", :id => "myid"} My paragraph
Inserting ruby code
You can insert ruby code with the = and - signs.
= link_to "Home", root_path
Code starting with = will be executed and embedded into the document.
Code starting with - will be executed, but not inserted into the document.
Policy for Use of Convert Html To Haml
1. All the data is safe and secure
2. Ovdss is never responsible to any unwanted activity make by user.
3. Adhere to all local, state, and federal laws while using the tool.
4. Engage respectfully with other users; no harassment, bullying, or hate speech.
5. Respect copyright and intellectual property rights; do not share unauthorized content.
6. Report any bugs, violations, or inappropriate behavior using the feedback option in this page.
7. Contributions (reviews, comments, etc.) should be honest and constructive.
8. Ensure your device meets this tool minimum requirements for optimal performance.
9. Respect and protect the privacy of other users; do not share personal information without consent.
10. Minors or people below 13 years old are not allowed to use this tool.
11. Restriction on using this tool in violation of applicable laws and regulations, or in any manner that may cause harm to any person, or any business entity.
These points help in creating a safe, respectful, and efficient environment for all users of the tool.