, , -, .
:
https://github.com/agoragames/stache
, , stache rails, Demo Demo App.
, mustache, stache Gemfile bundle install.
config/application.rb stache mustache ( handlebars; github).
Stache.configure do |config|
config.use :mustache
end
:
app/
controllers/
noises_controller.rb
models/
noise.rb
templates/
noises/
animal.mustache
views/
noises/
animal.rb
controllers/noises_controller.rb
class NoisesController < ApplicationController
def animal
end
end
models/noise.rb
class Noise < ActiveRecord::Base
def self.dog
"ar roof"
end
def self.sheep
"baa"
end
def self.bullfrog
"borborygmus"
end
end
templates/noises/animal.mustache
<p>This is what a dog sounds like: {{ dog }}</p>
<p>This is what a sheep sounds like: {{ sheep }}</p>
<p>And bullfrogs can sound like: {{ bullfrog }}</p>
views/noises/animal.rb
module Noises
class Animal < Stache::Mustache::View
def dog
Noise.dog
end
def sheep
Noise.sheep
end
def bullfrog
Noise.bullfrog
end
end
end
, , - stache mustache rails .