diff --git a/README.md b/README.md index ea825629..3dd7332f 100644 --- a/README.md +++ b/README.md @@ -15,29 +15,38 @@ that's both powerful and easy to understand. Haml can be used from the command line or as part of a Ruby web framework. The first step is to install the gem: - gem install haml +```sh +gem install haml +``` After you write some Haml, you can run - haml document.haml +```sh +haml document.haml +``` to compile it to HTML. For more information on these commands, check out - haml --help +```sh +haml --help +``` -To use Haml programatically, check out the [YARD -documentation](http://haml.info/docs/yardoc/). +To use Haml programatically, check out the [YARD documentation](http://haml.info/docs/yardoc/). ## Using Haml with Rails To use Haml with Rails, simply add Haml to your Gemfile and run `bundle`. - gem 'haml' +```ruby +gem 'haml' +``` Haml 4.1 requires an actively maintained version of Rails (version 3.2 or later). If you are using Rails 3.0 or 3.1, you should use Haml version 4.0.x: - gem 'haml', '~> 4.0.4' +```ruby +gem 'haml', '~> 4.0.5' +``` If you'd like to replace Rails's Erb-based generators with Haml, add [haml-rails](https://github.com/indirect/haml-rails) to your Gemfile as well. @@ -46,58 +55,76 @@ If you'd like to replace Rails's Erb-based generators with Haml, add The most basic element of Haml is a shorthand for creating HTML: - %tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents +```haml +%tagname{:attr1 => 'value1', :attr2 => 'value2'} Contents +``` No end-tag is needed; Haml handles that automatically. If you prefer HTML-style attributes, you can also use: - %tagname(attr1='value1' attr2='value2') Contents +```haml +%tagname(attr1='value1' attr2='value2') Contents +``` Adding `class` and `id` attributes is even easier. Haml uses the same syntax as the CSS that styles the document: - %tagname#id.class +```haml +%tagname#id.class +``` In fact, when you're using the `