No commit activity in last 3 years
No release in over a year
Implements Mustache views and templates for Rails 6.x
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 6.0, < 7
~> 1.1.0
 Project Readme

Mustache Rails

Implements Mustache views and templates for Rails 3.x

Installation

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:

# app/views/layouts/application.rb
module Views
  module Layouts
    class Application < ActionView::Mustache
      def title
        "Hello"
      end
    end
  end
end
{{ ! app/templates/layouts/application.mustache }}
<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8'>
  <title>{{title}}</title>
</head>
<body>
  {{yield}}
</body>
</html>
# app/views/users/show.rb
module Views
  module Users
    class Show < Layouts::Application
      attr_reader :user
    end
  end
end
{{ ! app/templates/users/show.mustache }}
{{#user}}
  <h1>{{name}}</h1>
{{/user}}

Optional Configuration

# 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.