This is a user sandbox of
Abhat198. You can use it for testing or practicing edits. This is not the sandbox where you should draft your assigned article for a dashboard.wikiedu.org course. To find the right sandbox for your assignment, visit your Dashboard course page and follow the Sandbox Draft link for your assigned article in the My Articles section. |
Paradigm | Template engine |
---|---|
Designed by | Nick Walsh |
Developer | Norman Clarke, Matt Wildig, Akira Matsuda, Tee Parham |
Stable release | 4.0.7
/ August 10, 2015[1]
|
Implementation language | Ruby |
OS | Cross-platform |
License | MIT License |
Filename extensions | .haml |
Website |
haml |
Haml ( HTML Abstraction Markup Language) is a templating system to avoid writing the inline code in a web document and make HTML easy and clean. Haml gives the flexibility to have some dynamic content in HTML. Similar to other web languages like PHP, ASP, JSP and template systems like eRuby, Haml also embeds some code that gets executed during runtime and generates HTML code in order to provide some dynamic content. In order to run Haml code, files need to have .haml extension. These files are similar to .erb or eRuby files which also help to embed Ruby code while developing a web application. While parsing coding comments Haml uses the same rules as Ruby 1.9 or later. Haml understands only ASCII compatible encodings like UTF-8 but does not understand UTF-16 or UTF-32, since these are not compatible with ASCII. [2] [3] Haml can be used in command line, as a separate Ruby module or can be used in a Ruby on Rails application making Haml suitable for a wide range of applications.
Haml was originally introduced by Hampton Catlin with its initial release in 2006 [4] and the work was taken ahead by a few other people. [5] His motive was to make HTML simpler, cleaner and easier to use. Since 2006, it has been revised several times and newer versions were released. In April 2012, the maintenance of Haml was taken up by Norman Clarke. [5] Natalie Weizenbaum and Nick Walsh were the few others who helped in developing Haml and making it what it is now. Natalie Weizenbaum worked on making Haml usable in ruby applications, while the branding and design was done by Nick Walsh. [5] Others who are currently in the maintenance team are Matt Wildig, Akira Matsuda and Tee Parham. [6]
The latest version of Haml as a rubygem is 4.0.7 and 4.1.0 series has been out with its alpha and beta versions. [7]. Several amendments like increasing the performance, fixing a few warnings, compatibility with latest versions of Rails, fixes in the documentation and many more were made in the Haml 4 series. [1] The 5th version is unreleased [1] and is compatible with only Ruby 2.0.0 or above and does not support Rails 3. [1] Trace option has been added and certain memory and performance enhancements have also been made. [1]
Haml's implementation is licensed under the MIT License and some of the work was also supported by Unspace Interactive. [6]
There were four principles involved in development of Haml. [5]
Markup language is user-friendly if it adheres to following features:
Markup language should adhere to DRY principle. It should:
Markup language with good indentation improves appearance, makes it easy to read for readers and also to determine where a given element starts and ends.
Markup language with a clear structure will help in code maintenance and logical understanding of final result.
Haml markup is similar to
CSS in syntax. For example, Haml has the same dot .
representation for classes as CSS does, making it easy for developers to use this markup.
A simple Hello World implementation in Haml would be:
%p{:class => "sample", :id => "welcome"} Hello, World!
This renders to this HTML code:
<p class="code" id="message">Hello, World!</p>
To run Haml code, Haml
gem must be installed as follows:
[8]
gem install haml
Haml code that is saved to a file named as Hello.haml
, can be run as follows:
haml Hello.haml
To use Haml with Ruby, the Ruby Gemfile
should include this line:
gem 'haml'
Similar to ERB, Haml also can access local variables (declared within same file in Ruby code). This example uses a sample Ruby controller file. [8]
//file: app/controllers/messages_controller.rb
class MessagesController < ApplicationController
def index
@message = "Hello, World!"
end
end
//file: app/views/messages/index.html.haml
#welcome
%p= @message
This renders to
<div id="welcome">
<p>Hello, World!</p>
</div>
To use Haml independent of
Rails and
ActionView, install haml
gem, include it in Gemfile
and simply require it in Ruby script or invoke Ruby interpreter with -rubygems
flag.
welcome = Haml::Engine.new("%p Hello, World!")
welcome.render
Output:
<p>Hello, World!</p>
Haml::Engine is a Haml class.
The following example demonstrates differences between Haml and ERB (Embedded Ruby).
//Haml:
%div.category
%p.recipes
%h1= recipe.name
%h3= recipe.category
%h4= recipe.description
|
//ERB:
<div class=”category”>
<div class="recipes">
<h1><%= recipe.name %></h1>
<h3><%= recipe.category %></h3>
</div>
<div>
<h4><%= recipe.description %></h4>
</div>
</div>
|
For a sample recipe information, the HTML code rendered by both the above code samples looks like:
//HTML:
<div class=”category”>
<div class="recipes">
<h1>Cookie</h1>
<h3>Desserts</h3>
</div>
<div>
<h4>Made from dough and sugar. Usually circular in shape and has about 400 calories.</h4>
</div>
</div>
Key differences are:
class
, id
can be represented by #
, .
respectively instead of regular class
and id
keywords. Haml also uses %
to indicate a HTML element instead of <>
as in ERB.The official implementation of Haml has been built for Ruby with plugins for Ruby on Rails and Merb, but the Ruby implementation also functions independently. Haml can be easily used along with other languages. Below is a list of languages in which Haml has implementations:
Category:Ruby (programming language) Category:Template engines Category:Free computer libraries Category:Software using the MIT license Category:Lightweight markup languages
This is a user sandbox of
Abhat198. You can use it for testing or practicing edits. This is not the sandbox where you should draft your assigned article for a dashboard.wikiedu.org course. To find the right sandbox for your assignment, visit your Dashboard course page and follow the Sandbox Draft link for your assigned article in the My Articles section. |
Paradigm | Template engine |
---|---|
Designed by | Nick Walsh |
Developer | Norman Clarke, Matt Wildig, Akira Matsuda, Tee Parham |
Stable release | 4.0.7
/ August 10, 2015[1]
|
Implementation language | Ruby |
OS | Cross-platform |
License | MIT License |
Filename extensions | .haml |
Website |
haml |
Haml ( HTML Abstraction Markup Language) is a templating system to avoid writing the inline code in a web document and make HTML easy and clean. Haml gives the flexibility to have some dynamic content in HTML. Similar to other web languages like PHP, ASP, JSP and template systems like eRuby, Haml also embeds some code that gets executed during runtime and generates HTML code in order to provide some dynamic content. In order to run Haml code, files need to have .haml extension. These files are similar to .erb or eRuby files which also help to embed Ruby code while developing a web application. While parsing coding comments Haml uses the same rules as Ruby 1.9 or later. Haml understands only ASCII compatible encodings like UTF-8 but does not understand UTF-16 or UTF-32, since these are not compatible with ASCII. [2] [3] Haml can be used in command line, as a separate Ruby module or can be used in a Ruby on Rails application making Haml suitable for a wide range of applications.
Haml was originally introduced by Hampton Catlin with its initial release in 2006 [4] and the work was taken ahead by a few other people. [5] His motive was to make HTML simpler, cleaner and easier to use. Since 2006, it has been revised several times and newer versions were released. In April 2012, the maintenance of Haml was taken up by Norman Clarke. [5] Natalie Weizenbaum and Nick Walsh were the few others who helped in developing Haml and making it what it is now. Natalie Weizenbaum worked on making Haml usable in ruby applications, while the branding and design was done by Nick Walsh. [5] Others who are currently in the maintenance team are Matt Wildig, Akira Matsuda and Tee Parham. [6]
The latest version of Haml as a rubygem is 4.0.7 and 4.1.0 series has been out with its alpha and beta versions. [7]. Several amendments like increasing the performance, fixing a few warnings, compatibility with latest versions of Rails, fixes in the documentation and many more were made in the Haml 4 series. [1] The 5th version is unreleased [1] and is compatible with only Ruby 2.0.0 or above and does not support Rails 3. [1] Trace option has been added and certain memory and performance enhancements have also been made. [1]
Haml's implementation is licensed under the MIT License and some of the work was also supported by Unspace Interactive. [6]
There were four principles involved in development of Haml. [5]
Markup language is user-friendly if it adheres to following features:
Markup language should adhere to DRY principle. It should:
Markup language with good indentation improves appearance, makes it easy to read for readers and also to determine where a given element starts and ends.
Markup language with a clear structure will help in code maintenance and logical understanding of final result.
Haml markup is similar to
CSS in syntax. For example, Haml has the same dot .
representation for classes as CSS does, making it easy for developers to use this markup.
A simple Hello World implementation in Haml would be:
%p{:class => "sample", :id => "welcome"} Hello, World!
This renders to this HTML code:
<p class="code" id="message">Hello, World!</p>
To run Haml code, Haml
gem must be installed as follows:
[8]
gem install haml
Haml code that is saved to a file named as Hello.haml
, can be run as follows:
haml Hello.haml
To use Haml with Ruby, the Ruby Gemfile
should include this line:
gem 'haml'
Similar to ERB, Haml also can access local variables (declared within same file in Ruby code). This example uses a sample Ruby controller file. [8]
//file: app/controllers/messages_controller.rb
class MessagesController < ApplicationController
def index
@message = "Hello, World!"
end
end
//file: app/views/messages/index.html.haml
#welcome
%p= @message
This renders to
<div id="welcome">
<p>Hello, World!</p>
</div>
To use Haml independent of
Rails and
ActionView, install haml
gem, include it in Gemfile
and simply require it in Ruby script or invoke Ruby interpreter with -rubygems
flag.
welcome = Haml::Engine.new("%p Hello, World!")
welcome.render
Output:
<p>Hello, World!</p>
Haml::Engine is a Haml class.
The following example demonstrates differences between Haml and ERB (Embedded Ruby).
//Haml:
%div.category
%p.recipes
%h1= recipe.name
%h3= recipe.category
%h4= recipe.description
|
//ERB:
<div class=”category”>
<div class="recipes">
<h1><%= recipe.name %></h1>
<h3><%= recipe.category %></h3>
</div>
<div>
<h4><%= recipe.description %></h4>
</div>
</div>
|
For a sample recipe information, the HTML code rendered by both the above code samples looks like:
//HTML:
<div class=”category”>
<div class="recipes">
<h1>Cookie</h1>
<h3>Desserts</h3>
</div>
<div>
<h4>Made from dough and sugar. Usually circular in shape and has about 400 calories.</h4>
</div>
</div>
Key differences are:
class
, id
can be represented by #
, .
respectively instead of regular class
and id
keywords. Haml also uses %
to indicate a HTML element instead of <>
as in ERB.The official implementation of Haml has been built for Ruby with plugins for Ruby on Rails and Merb, but the Ruby implementation also functions independently. Haml can be easily used along with other languages. Below is a list of languages in which Haml has implementations:
Category:Ruby (programming language) Category:Template engines Category:Free computer libraries Category:Software using the MIT license Category:Lightweight markup languages