Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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.