Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/autolist/mustache-rails
Fork of mysteriously gone josh/mustache-rails
https://github.com/autolist/mustache-rails
Last synced: 8 days ago
JSON representation
Fork of mysteriously gone josh/mustache-rails
- Host: GitHub
- URL: https://github.com/autolist/mustache-rails
- Owner: autolist
- License: mit
- Created: 2015-06-01T17:03:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-01T17:03:35.000Z (over 9 years ago)
- Last Synced: 2023-03-01T04:11:41.816Z (over 1 year ago)
- Language: Ruby
- Size: 131 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- 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.