Next is making html and js for test.$wget http://code.jquery.com/jquery-1.10.1.min.js $git clone https://github.com/documentcloud/underscore.git $cp underscore/underscore-min.js . $git clone https://github.com/douglascrockford/JSON-js.git $cp JSON-js/json2.js . $wget http://backbonejs.org/backbone-min.js
<!DOCTYPE html> <html> <head> <title>Backbone Example</title> </head> <body> <h1>Backbone Example</h1> <script src="jquery-1.10.1.min.js"></script> <script src="json2.js"></script> <script src="underscore-min.js"></script> <script src="backbone-min.js"></script> <script src="js/app.js"></script> </body> </html>
Try to access with browser.(function() { console.log("Hello Backbone!"); }());
Prepare Cakefile for building.{ "name": "sample", "version": "0.0.1", "dependencies": { "coffee-script": "*", "jasmine-node": "*", "grunt": "*" } } $npm install
Preparing is over.fs = require 'fs' path = require 'path' {spawn, exec} = require 'child_process' coffee = (args) -> proc = spawn './node_modules/.bin/coffee', args proc.stderr.on 'data', (buffer) -> console.log buffer.toString() proc.on 'exit', (status) -> process.exit(1) if status != 0 jasmine = (args) -> proc = spawn './node_modules/.bin/jasmine-node', args proc.stdout.on 'data', (buffer) -> console.log buffer.toString() proc.on 'exit', (status) -> process.exit(1) if status != 0 task 'build', "build source files in './src' to './build'", -> target = [ 'src/main' ] coffee ['-j','tmp','-o','lib','-c'].concat target exec 'sleep 1 && cat build/tmp.js | grep -v "exports\." | grep -v "require(" > build/app.js', (err) -> throw err if err task 'buildspec', "build source files in './spec' to './lib'", -> target = [ 'src/main' 'spec/main_spec' ] coffee ['-j','tmpspec','-o','lib','-c'].concat target exec 'sleep 1 && cat build/tmpspec.js | grep -v "exports\." | grep -v "require(" > build/main_spec.js', (err) -> throw err if err task 'clean', 'clean out temporary build files', -> if fs.readdirSync('lib/').length > 0 exec 'rm js/*.js', (err) -> throw err if err task 'spectest', 'run jasmine-node spec suite', -> invoke 'build' jasmine ['--coffee','--verbose','spec/'] task 'all', 'clean and build all', -> invoke 'clean' invoke 'build' invoke 'buildspec'
Try to access with browser. 参考ページ:http://appkitbox.com/knowledge/javascript/2013/03/15/backbone-1$vim src/app.coffee obj = new Backbone.Model() obj.set({name: "Murata"}) obj.set({age: 20}) console.log "obj: " + JSON.stringify(obj) console.log "obj.name: " + obj.get("name") $cake build
Streamlit is a …
I bought M5Stac…