HTML+ERB to Haml
Convert HTML/ERB to Haml template code
Introduction
This is an online converter tool which helps to convert HTML+ERB to Haml template.
How to use this tool?
You can input/paste your code directly into the editor, then click the Convert button. After converting, you can download or save/share the result. It will create a link for you to share with others. You can also sign-in using Google/GitHub to save results into your account.
What is Haml?
Haml is a markup language that’s used to cleanly and simply describe the HTML of any web document without the use of inline code. Haml functions as a replacement for inline page templating systems such as PHP, ASP, and ERB, the templating language used in most Ruby on Rails applications. However, Haml avoids the need for explicitly coding HTML into the template, because it itself is a description of the HTML, with some code to generate dynamic content.
Unspace Interactive and several other professional Rails shops use Haml exclusively for their projects, valuing its focus on cleanliness, readability, and production speed.
Haml Syntax
%section.container
%h1= post.title
%h2= post.subtitle
.content
= post.content
Examples
HTML+ERB
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<h1>Blogg</h1>
<p>
Time:
<%= Time.now %>
</p>
<% Post.all.each do |post| %>
<article>
<h2><%= post.title %></h2>
<div><%= post.body %></div>
</article>
<% end %>
</body>
</html>
Haml
!!!
%html
%head
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%meta{:charset => "utf-8"}/
%body
%h1 Blogg
%p
Time:
\#{Time.now}
- Post.all.each do |post|
%article
%h2= post.title
%div= post.body