yui-pathogen-encoder
Version:
Enables pathogen encoding in YUI Loader
78 lines (59 loc) • 1.92 kB
JavaScript
/*
* Copyright (c) 2013, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
/*jslint node:true, nomen: true */
/**
The `yui.cdn` extension that provides some basic configuration
that will facilitate the configuration of YUI to be served from
CDN as well as custom groups to be configured to be served from
and alternative CDN as well.
@module yui
@submodule cdn
**/
;
var utils = require('./utils');
/**
The `yui.cdn` extension provides some basic configuration
that facilitates the configuration of YUI to be served from
CDN.
Explicitly defines to boot YUI from YUI CDN in the client runtime.
This is the default behavior, but in some cases, when defining a
custom base and root for all groups you might want to set YUI
straight to the original YUI CDN. In the following example you can
see how to force yui to load from CDN.
var express = require('express'),
expyui = require('express-yui'),
app = express();
expyui.extend(app);
app.yui.setCoreFromCDN();
@class cdn
@static
@uses utils
@extensionfor yui
*/
module.exports = {
/**
Set up a default group in loader that represents the
core yui modules to be loaded from YUI CDN.
app.yui.setCoreFromCDN();
@method setCoreFromCDN
@public
@param {Object} loaderConfig Optional loader configuration
objects that, if passed, will be mix with the default
configuration for yui CDN.
@chainable
**/
setCoreFromCDN: function (loaderConfig) {
var config = this.config(),
version = this.version;
utils.extend(config, {
base: "http://yui.yahooapis.com/" + version + "/",
comboBase: "http://yui.yahooapis.com/combo?",
comboSep: "&",
root: version + "/"
}, loaderConfig);
return this;
}
};