Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emancu/cuba-haml
A Cuba plugin to use Haml
https://github.com/emancu/cuba-haml
Last synced: 24 days ago
JSON representation
A Cuba plugin to use Haml
- Host: GitHub
- URL: https://github.com/emancu/cuba-haml
- Owner: emancu
- Created: 2012-10-05T15:57:22.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-11-13T15:24:48.000Z (about 12 years ago)
- Last Synced: 2024-03-15T12:12:52.707Z (10 months ago)
- Language: Ruby
- Size: 117 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
cuba-haml
=========A Cuba plugin to use Haml
Configure
---------__Cuba::Haml__ plugin introduces some __keys__ into _Cuba.settings_ to make easy the way to reander layouts
``` ruby
# Default layouts directory
app.settings[:haml][:layout_path] ||= app.settings[:haml][:views]
# Default layout file
app.settings[:haml][:layout] ||= "layout"
```Feel free to overwrite this variables after install the plugin. Following this example
``` ruby
require "cuba/haml"Cuba.plugin Cuba::Haml
Cuba.settings[:haml][:layout_path] = "some/other/path"
Cuba.settings[:haml][:layout] = "not_default_layout"
```Rendering
---------Cuba ships with a plugin that provides helpers for rendering templates.
But if only want to use haml, you can specify this plugin.``` ruby
require "cuba/haml"Cuba.plugin Cuba::Haml
Cuba.define do
on default do# Within the partial, you will have access to the local variable `content`,
# that will hold the value "hello, world".
res.write render("home.haml", content: "hello, world")
end
end
```Using the method __render__, you need to provide _full path template_ so there are two methods to do it easy
`template_path(template_name)` and `layout_path(layout).`But you can use the __haml__ helper to get a cleaner code
``` ruby
...
on default do
haml("home", content: "hello, world")
end
...
```Also if you want to override the _default layout_ you can use the __view__ helper
``` ruby
...
on default do
view("home", 'other-layout', content: "hello, world")
end
...
```Don't be afraid and read the tests, there are really simple I promisse!
> Note that in order to use this plugin you need to have [Haml](https://github.com/haml/haml) installed.