A example project lets require-ls (A RequireJS loader plugin for LiveScript) and Backbone.js work together.
Try to modularize Backbone's code with LiveScript.
The original code from Backbone's example.
First, I re-organize to keep html, css, pic, .js of app (todos.js
) in todos/
folder and put .js of libraries in todos/lib/
folder … index_bk.html
is original index.html
.
Second, write bootstrap files (app/main.js
, app/lsmain.ls
) for require-ls, and divide todos.js
into model/view folders (app/model/*.js
, app/view/*.js
).
Finally, convert app/model/*.js
, app/view/*.js
to app/model/*.ls
, app/view/*.ls
.
-
git clone this repo
git clone https://github.com/tcc/require-ls-backbone.git
-
Firfox open
todos/index.html
as local file, otherwise it needs local web server (for require-ls).
Modify todos\app\lsmain.js
as:
define ['app/view/app'], (AppView) ->
$ -> new AppView
(Change 'ls:app/view/app'
to app/view/app
)
Keep todos\app\lsmain.js
as:
define ['ls:app/view/app'], (AppView) ->
$ -> new AppView
- class version like requirejs-coffeescript-backbone-jquery-bootstrap.