Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Shared Templates for Rails 3

Alexey
October 01, 2012

Shared Templates for Rails 3

Shared Templates for Rails 3

Alexey

October 01, 2012
Tweet

Other Decks in Programming

Transcript

  1. Ways to render web interface • Rails render content on

    backend and send it to browser • Rails backend have only REST API and interface rendered by JavaScript in web application
  2. Hybrid web application • Interface part rendered on backend and

    part rendered on frontend • Very often need to use the same templates for backend and frontend • We need DRY!
  3. smt_rails • smt_rails (Shared Mustache Templates for Rails 3) •

    gem 'smt_rails' • rails g smt_rails:install • You're done!
  4. Example Template: Hello {{msg}}!!! ActionView: <%= render "tests/test", :mustache =>

    {msg: "Test"} %> JavaScript: var content = SMT['tests/test']({msg: "Test"});