https://github.com/masylum/trimmer
Rack endpoint to make templates and i18n translations available in javascript
https://github.com/masylum/trimmer
Last synced: over 1 year ago
JSON representation
Rack endpoint to make templates and i18n translations available in javascript
- Host: GitHub
- URL: https://github.com/masylum/trimmer
- Owner: masylum
- Created: 2012-02-21T15:47:32.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-01-25T13:42:10.000Z (over 14 years ago)
- Last Synced: 2025-01-22T12:32:41.005Z (over 1 year ago)
- Language: Ruby
- Homepage: https://github.com/teambox/trimmer
- Size: 77.1 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
Awesome Lists containing this project
README
Trimmer Controller
=================
Rack endpoint to make templates and i18n translations available in javascript.
See specs for more details.
How it works
------------
Trimmer adds additional routes to your app:
- /trimmer/en.js
- /trimmer/es.js
- etc
This defines two variables in your app: I18n.translations and Templates.
Translations
------------
Trimmer will serve the translations you define from your config/locales files available as a JS object.
Templates
---------
This is the cool part. You can define your own structure of client-side templates which will be:
1. Rendered by Rails (where you can access ERB, helpers and Rails i18n)
2. Available in JS as templates
To add templates, create a folder structure like this:
app/
templates/
users/
index.jade.erb
show.jade.erb
settings.jade.erb
This will create a JS object with this structure:
Templates = {
users: {
index: "...",
show: "..."
},
settings: "..."
}