nodulator-assets v0.0.9
Nodulator-Assets
Assets and views automatic management system for Nodulator
Released under GPLv2
Concept
Provides ability to Nodulator to render views and auto-load assets in following folders:
Nodulator.config.js: array for js (or coffee) filesNodulator.config.css: array for css filesNodulator.config.viewRoot: path for index.jade
Features
- Automatic js and css assets loading
- Provides methods for modules to add folders to assets management
- Provides basic view system (only '
Nodulator.config.viewRoot/index.jade' for the moment) - Add a
Nodulator.Run()method to be called last for view rendering - Add a
Nodulator.ExtendBeforeRun()andNodulator.ExtendAfterRun()method for modules to add instructions at the begining ofRun()or just beforeRender() - Add a
Nodulator.ExtendBeforeRender()andNodulator.ExtendAfterRender()method for modules to add instructions at the begining ofRender()or just before the actualres.render() - CoffeeScript automatic compilation on fly
- Jade automatic compilation on fly (no other engines yet)
JumpTo
Installation
You can automaticaly install Nodulator and Nodulator-Assets by running
$> sudo npm install -g Nodulator
$> Nodulator install assetsOr you can just run npm :
$> npm install nodulator nodulator-assetsBasics
Nodulator = require 'nodulator'
Assets = require 'nodulator-assets'
# Default config, can be omited
Nodulator.Config
viewRoot: 'client'
js: ['/client/public/js/', '/client/']
css: ['/client/public/css/']
engine: 'jade' # no other engines at the moment
Nodulator.Use Assets
# New method, to be called last for rendering
Nodulator.Run()In index.jade, you must always call | !{nodulator()} at the end of the file.
It's there that all Nodulator-Assets magic stuff occur, and the only call you'll ever have to do in views.
Project Generation
See Nodulator's project generation
When calling $> Nodulator init, it will automaticaly create following structure if non-existant:
client
├── index.jade
└── public
├── css
├── img
└── jsModule Hacking
The module is stored in Nodulator.assets and provides following methods :
# Add folders given in list to assets list
Nodulator.assets.AddFolder (list) ->
# Add folders given in list to assets list, the recursive way
Nodulator.assets.AddFolderRec (list) ->Exemple of asset list : (paths are relative to project root)
list =
'/js/app.js': ['/client/folder1/']
'/css/app.css': ['/client/public/css/']TODO
- Test suite
- Image (and other static assets) management
- Split assets between
headandbodytags
Changelog
XX/XX/XX: Current (not released yet)
- Added a parameter to view nodulator() function to get a specific set of assets
12/02/15: v0.0.9
- Added fake tests
- Updated README
03/01/15: v0.0.8
- Added
Nodulator.ExtendBeforeRender()andNodulator.ExtendAfterRender()to precisely extend render process.
02/01/15: v0.0.7
- Updated README
02/01/15: v0.0.6
- Changed
Nodulator.ExtendRunProcessintoNodulator.ExtendBeforeRun - Added
Nodulator.ExtendAfterRun - That fixes cachify_js bug if another render is processed
02/01/15: v0.0.5
- Added index.jade file generation
- Changed the way folders are configurated
- Improved README
- Files are automaticaly loaded by
!{nodulator()}call - Added automatic compilation of views