Tutorial¶
Presentation of Spear.js¶
Spear.js is a lightweight framework in JavaScript to separate web applications in multiples manageable components called widgets.
Spear.js is not a full featured framework that can handle all aspects of a web application like network communications or routing. There are good libraries for that. Spear.js only handles one aspect of web development: separation of visual components into separate entities, and it tries to do it as best as it cans.
Quickstart¶
The easiest way to start a Spear.js application is to checkout the sample application. Using git, do this:
git clone https://github.com/nicolas-van/spear.js-starter.git
This sample application uses bower, npm and grunt to download the dependencies and launch a small web server. Type these lines to download everything and start the server:
bower install
npm install
grunt
Then head your web browser to http://localhost:9000 and you will see the Hello World message outputed by
the application.
A Word About Template Engines¶
Spear.js is a lightweight framework. As such, it doesn’t impose a particular template engine to render HTML. The sample application uses Nunjucks from Mozilla as it is a high quality and full featured template engine in JavaScript, but you are free to replace it by any other template engine.