Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dasch/mustache-rails
Mustache Rails adapter
https://github.com/dasch/mustache-rails
Last synced: 24 days ago
JSON representation
Mustache Rails adapter
- Host: GitHub
- URL: https://github.com/dasch/mustache-rails
- Owner: dasch
- License: mit
- Created: 2012-06-14T12:55:31.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-06-15T11:12:22.000Z (over 12 years ago)
- Last Synced: 2023-04-11T15:32:53.412Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 122 KB
- Stars: 1
- Watchers: 1
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mustache Rails
Implements Mustache views and templates for Rails 3.x
## Installation
``` ruby
gem "mustache-rails", :require => "mustache/railtie"
```Or alternatively `require 'mustache/railtie'` in your `config/application.rb`.
## Usage
In typical mustache fashion, `.mustache` templates go under `app/templates` and view `.rb` files go under `app/views`. Any view classes will be looked for under the `::Views` modules.
Simple template scaffolding:
``` ruby
# app/views/layouts/application.rb
module Views
module Layouts
class Application < ActionView::Mustache
def title
"Hello"
end
end
end
end
`````` mustache
{{ ! app/templates/layouts/application.mustache }}
{{title}}{{yield}}
```
``` ruby
# app/views/users/show.rb
module Views
module Users
class Show < Layouts::Application
attr_reader :user
end
end
end
`````` mustache
{{ ! app/templates/users/show.mustache }}
{{#user}}
{{name}}
{{/user}}
```### Optional Configuration
``` ruby
# config/application.rb
module Foo
class Application < Rails::Application
# Config defaults
config.mustache.template_path = "app/templates"
config.mustache.view_path = "app/views"
config.mustache.view_namespace = "::Views"
end
end
```## License
Copyright © 2012 Joshua Peek.
Released under the MIT license. See `LICENSE` for details.