An example of using backbone.js models, collections and view with HTML rendered from Sinatra/Datamapper.
JavaScript Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
db
public/javascripts
views
.gitignore
Gemfile
README
README.markdown
application.rb
config.ru

README.markdown

Backbone with server side rendering

Backbone.js is a great tool for organizing your javascript code into models, collections and views, without tying your data to the DOM elements. However, most tutorials show how to render the HTML only via Backbone (client-side), which means that none of your content is crawled by search engines. This is possibly a major problem if you're not making an app hidden behind an authentication system.

This is a small example app written in Ruby / Sinatra that shows how to render your initial page with your Sinatra models (here using Datamapper YAML), and then handle events and DOM updates with Backbone.

The app renders HTML and create corresponding Backbone models, passing in the already existing DOM element.

Feel free to fork and make changes.