1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
HTML Abstraction Markup Language - A Markup Haiku
Find a file
Takashi Kokubun c0190ef3ce Change local CI test script name
because Rakefile execution locks Ruby version
2015-06-07 17:32:15 +09:00
benchmarks Remove escape_html from benchmark 2015-04-12 19:20:53 +09:00
bin Add hamlit cli 2015-03-15 13:54:54 +09:00
lib Refactor whitespace compiler 2015-06-07 15:55:44 +09:00
spec Manage compatibilities with other implementations 2015-06-07 17:26:37 +09:00
.gitignore Integrate with tilt and add sass filter 2015-03-30 20:15:46 +09:00
.rspec Revert "Fix bundle exec rspec to work" 2015-03-29 00:11:36 +09:00
.travis.yml Increase benchmark iteration 2015-04-06 22:20:56 +09:00
CHANGELOG.md Bump up version 2015-06-06 13:42:14 +09:00
Gemfile Name the gem "hamlit" 2015-03-15 00:08:47 +09:00
hamlit.gemspec Drop support of Ruby 1.9 2015-04-19 14:01:07 +09:00
LICENSE.txt Make plain text parser better 2015-03-30 14:12:02 +09:00
Rakefile Change local CI test script name 2015-06-07 17:32:15 +09:00
README.md Update README.md 2015-05-16 12:25:38 +09:00
release Change local CI test script name 2015-06-07 17:32:15 +09:00
test Change local CI test script name 2015-06-07 17:32:15 +09:00

Hamlit Build Status

Hamlit is a high performance haml implementation.

Installation

Add this line to your application's Gemfile:

gem 'hamlit'

or just replace gem "haml" with gem "hamlit".

Features

Fast rendering

Hamlit's rendering is 7.16x times faster than original haml.

    erubis:   114501.6 i/s
    hamlit:   112888.1 i/s - 1.01x slower
      slim:   103298.5 i/s - 1.11x slower
      faml:    88675.4 i/s - 1.29x slower
      haml:    15750.6 i/s - 7.27x slower

This benchmark is the same as slim-template/slim's one for fairness. (The result on travis CI)

Better parser

Haml's attribute parser is not so good. For example, raises syntax error for %a{ b: '}' }. Hamlit's attribute parser is implemented with Ripper, which is an official lexer for Ruby, so it is able to parse such an attribute.

Passing haml-spec

haml/haml-spec is a basic suite of tests for Haml interpreters. For all test cases in haml-spec, Hamlit behaves the same as Haml (ugly and escape_html mode only, which is used on production).

Hamlit is used on githubranking.com.

Usage

Basically the same as haml. Check out the reference documentation for details.

Rails

Just update Gemfile.

Sinatra

Update Gemfile. Html escaping is enabled by default. If you want to disable it, add following code.

set :haml, { escape_html: false }

Why high performance?

Less work on runtime

Haml's rendering is very slow because generated code by haml runs many operations on runtime. For example, Haml::Util is extended on view, attribute rendering runs even if it is a static value and the values in attribute is sorted. All of them is achieved on runtime.

Hamlit extends ActionView beforehand, attribute rendering is done when compiled if it is a static hash and no unnecessary operation is done on runtime.

Temple optimizers

Hamlit is implemented with temple, which is a template engine framework for Ruby. Temple has some great optimizers for generated code. Thus generated code by Hamlit is very fast.

Not only relying on temple optimizers, but also Hamlit's compiler cares about many cases to optimize performance such as string interpolation.

License

MIT License