Lightweight html from ruby code builder. Inspired by Mab.
Installation
Add to Gemfile:
gem 'rhb'
Usage
Example:
builder = Rhb::Builder.new
builder.doctype
builder.html do
head do
title 'Awesome page'
link rel: 'stylesheet', href: 'style.css'
end
body id: :body do
h1 'My Awesome Page', class: 'awesome', data: { awesomeness: { level: 'high' } }
end
end
end
builder.to_html
Result:
<!DOCTYPE html><html><head><title>Awesome page</title><link rel="stylesheet" href="style.css"></head><body id="body"><h1 class="awesome" data-awesomeness-level="high">My Awesome Page</h1></body></html>
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request