HTML Abstraction Markup Language - A Markup Haiku
Ruby
Pull request Compare This branch is 4 commits ahead, 1091 commits behind haml:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
doc-src
ext
extra
lib
rails
test
vendor
yard
.gitignore
.gitmodules
.travis.yml
.yardopts
CONTRIBUTING
MIT-LICENSE
README.md
Rakefile
TODO
VERSION
VERSION_NAME
haml_ejs.gemspec
init.rb

README.md

Haml+ejs

Haml+ejs is a templating engine for client-side HTML templates. It's are designed to make it both easier and more pleasant to write HTML documents, by eliminating redundancy, reflecting the underlying structure that the document represents, and providing elegant, easily understandable, and powerful syntax.

Installing

Add the following to your project's Gemfile

gem 'haml_ejs'

Formatting

haml+ejs supports all of haml, plus some special EJS-producing directives. You can compile Haml+ejs templates to HTML mingled with EJS. For example:

%p
  ^= my_var
  ^if sunny
    Nice, eh?

compiles to:

<p>
  <%= my_var %>
  <% if (my_var) { %>
    Nice eh?
  <% } %>
</p>

The available EJS directives are:

^= Interpolate a JavaScript variable
^if Output nested content if JavaScript expression is truthy
^unless Output nested content if JavaScript expression is falsy
^elsif Output nested content if preceding JavaScript expression is falsy, and the provided expression is truthy
^else Output nested content if precending JavaScript expression is falsy
^each Iterate over the JavaScript collection, outputing the nested content once for each item in the collection

See the official Haml documentation for how to use Haml itself.