Skip to content

Commit

Permalink
Add basic usage to readme
Browse files Browse the repository at this point in the history
adambeynon committed Dec 4, 2013

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 4d1296f commit c52b37e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,44 @@

Haml templates for opal

## Usage

Add opal-haml to your `Gemfile`:

```ruby
gem 'opal-haml', :github => 'opal/opal-haml'
```

Create a haml file in the opal load path (e.g. `app/user_template.haml`):

```haml
.row
.col-md-6
= self.name
.col-md-6
= self.age
```

Render the haml template:

```ruby
# app/application.rb
require 'user_template'

class User
attr_accessor :name, :age

def initialize(name, age)
@name, @age = name age
end
end

user = User.new('Ford Perfect', 42)
html = Template['user_template'].render(user)
puts html
# => <div class="row">...</div>
```

## Running tests

Get dependencies:

0 comments on commit c52b37e

Please sign in to comment.