lib/parsers/css/injector.js
function injector(css, module, makeModule, options) {
  output_css      = join(options.output, options.css_folder   || 'css');
  location_css    = options.client + '/' + (options.css_folder || 'css');

  output_links    = join(options.output, options.links_folder || 'links');
  location_links  = options.client + '/' + (options.links_folder || 'links');

  // Unify css url (and store related assets in a sub directory 'links')
  css = rework(css)
    .use(unifyurl(module.path, output_links, location_links, options))
    .toString();

  // Create the css file
  var uid       = getUID(options) + getUID(css)
    , oFilename = uid + '.css'
    , oFilepath = join(output_css,   oFilename)
    , oLocation = location_css + '/' + oFilename
  ;

  write(oFilepath, css, {encoding:'utf8'})

  var js = tmpl.replace(/\{\{location\}\}/, oLocation);
  return jsParser(js, module, makeModule, options);
}
function injector(css, module, makeModule, options) {
  output_css      = join(options.output, options.css_folder   || 'css');
  location_css    = options.client + '/' + (options.css_folder || 'css');

  output_links    = join(options.output, options.links_folder || 'links');
  location_links  = options.client + '/' + (options.links_folder || 'links');

  // Unify css url (and store related assets in a sub directory 'links')
  css = rework(css)
    .use(unifyurl(module.path, output_links, location_links, options))
    .toString();

  // Create the css file
  var uid       = getUID(options) + getUID(css)
    , oFilename = uid + '.css'
    , oFilepath = join(output_css,   oFilename)
    , oLocation = location_css + '/' + oFilename
  ;

  write(oFilepath, css, {encoding:'utf8'})

  var js = tmpl.replace(/\{\{location\}\}/, oLocation);
  return jsParser(js, module, makeModule, options);
}
function injector ( css , module , makeModule , options ) { output_css = join ( options . output , options . css_folder || 'css' ) ; location_css = options . client + '/' + ( options . css_folder || 'css' ) ; output_links = join ( options . output , options . links_folder || 'links' ) ; location_links = options . client + '/' + ( options . links_folder || 'links' ) ; // Unify css url (and store related assets in a sub directory 'links') css = rework ( css ) . use ( unifyurl ( module . path , output_links , location_links , options ) ) . toString ( ) ; // Create the css file var uid = getUID ( options ) + getUID ( css ) , oFilename = uid + '.css' , oFilepath = join ( output_css , oFilename ) , oLocation = location_css + '/' + oFilename ; write ( oFilepath , css , { encoding : 'utf8' } ) var js = tmpl . replace ( / \{\{location\}\} / , oLocation ) ; return jsParser ( js , module , makeModule , options ) ; }
Injector module for css source

A nway parser function who create a nway javascript module
that offer a css injector for the css source.

The module exports:

- inject([media]): Inject css in the page (with a loaded promise)
may be called with a media attribute (default:all)
- eject(): remove css off the page
- injected *boolean*: The css is injected
- location *css*: The css location
Injector module for css source