Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opal/opal-haml
Opal + Haml = <3
https://github.com/opal/opal-haml
haml-template haml-templates opal opal-haml ruby
Last synced: 4 days ago
JSON representation
Opal + Haml = <3
- Host: GitHub
- URL: https://github.com/opal/opal-haml
- Owner: opal
- License: mit
- Created: 2013-12-03T20:01:01.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-01-28T19:16:19.000Z (9 months ago)
- Last Synced: 2024-04-24T14:38:05.398Z (6 months ago)
- Topics: haml-template, haml-templates, opal, opal-haml, ruby
- Language: Ruby
- Size: 56.6 KB
- Stars: 21
- Watchers: 9
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-opal - Opal Haml - Opal + Haml = <3 (Uncategorized / Uncategorized)
README
# Opal Haml
*Haml templates for Opal*
[![Build Status](https://travis-ci.org/opal/opal-haml.svg?branch=master)](https://travis-ci.org/opal/opal-haml)
This gem adds `.haml` files to sprockets to precompile templates for opal. This
gem does not make the haml compiler available under opal, just the result of
pre-compiling a haml template.A small runtime is included to handle dynamic attributes, as well as allowing
content to be rendered.All haml templates become available under the `Template` constant in Opal,
which allows a template to be easily rendered in a context:```ruby
Template['user'].render(my_user)
# =>..
```## Usage
Add opal-haml to your `Gemfile`:
```ruby
gem '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, :agedef initialize(name, age)
@name, @age = name, age
end
enduser = User.new('Ford Prefect', 42)
html = Template['user_template'].render(user)
puts html
# =>...
```## Running tests
Get dependencies:
```
$ bundle install
```Run tests using opal-rspec:
```
$ bundle exec rake
```Run specs in the browser:
```
$ bundle exec rackup
```## License
(The MIT License)
Copyright (C) 2013 by Adam Beynon, 2015 Elia Schito
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.