API Docs for: 0.2.0
Show:

seed Class

Uses
Defined in: lib/seed.js:20
Module: express-yui/lib/seed

Provision the seed information into app.yui.expose(), and it exposes an array of object with the information to build the script tag or tags that forms the seed:

The following is an example of how these features can be used:

var express = require('express'),
    expyui = require('express-yui'),
    app = express();

expyui.extend(app);
// adjust the seed modules
app.yui.seed(['yui-base', 'loader', 'foo', 'bar']);
// Call expose middleware when a route match.
app.get('/index.html', expyui.expose(), anotherRoute);

In the example above, the array of objects with all seed urls will be exposed thru window.YUI_config.seed, which means you can use it in in the client side to prepare the page to host a yui instance. Normally, you don't have to do this manually, you can use app.yui.ready() or app.yui.use() methods to do that task automatically. Here is an example of what you need in your layout template:

<script>
{{{state}}}
app.yui.ready(function () {
    // at this point, YUI is ready in the client, plus
    loader, foo and bar modules injected in the page
    since they were part or the seed.
});
</script>

Methods

_buildUrls

(
  • modules
  • ext
  • filterMap
  • customConfig
)
Array protected

Defined in lib/seed.js:230

Build a list of urls for a list of modules. Modules are described as <module-name>@<group-name>. Modules without the group denotation will be assumed as core modules from yui. ext denotates the type of the modules since this routine is able to produce css or js modules alike.

Parameters:

  • modules Array

    the array of modules to generate the urls.

  • ext String

    the modules extension, js or css.

  • filterMap Object

    hash table to translate filter values into suffix for modules. e.g.: min -> -min

  • customConfig Object

    optional configuration to overrule filter and combine per request when building the urls

    • filter String

      optional filter to overrule any filter

    • combine Boolean

      optional flag to overrule combine, when set to false, it will avoid creating combo urls.

Returns:

Array:

the href url for each link tag to be inserted in the header of the page

addModuleToSeed

(
  • moduleName
)
public chainable

Defined in lib/seed.js:105

Adds a yui module name into the core YUI configuration which is used by loader to identify the pieces that are already part of the seed and should be attached to Y automatically.

Parameters:

  • moduleName String

    the yui module name

buildCSSUrls

(
  • modules
)
Array public

Defined in lib/seed.js:209

Build a list of urls to load a list of css modules.

var links = app.yui.buildCSSUrls('cssbase', 'cssflickr@hermes');

As a result, links will be an array with the urls that you can use in your templates to provision styles.

Modules as cssflickr@hermes denotate a module from a particular group, as in <module-name>@<group-name>. Modules without the group denotation will be assumed as core modules from yui.

Parameters:

  • modules String multiple

    One or more module name (and optional @)

Returns:

Array:

the href url for each link tag to be inserted in the header of the page

buildJSUrls

(
  • modules
)
Array public

Defined in lib/seed.js:188

Build a list of urls to load a list of modules.

var scripts = app.yui.buildJSUrls('node', 'photos@hermes');

As a result, scripts will be an array with one or more urls that you can use in your templates to insert script tags.

Modules as photos@hermes denotate a module from a particular group, as in <module-name>@<group-name>. Modules without the group denotation will be assumed as core modules from yui.

Parameters:

  • modules String multiple

    One or more module name (and optional @)

Returns:

Array:

the src url for each script tag that forms the seed

getDefaultSeed

() Array protected

Defined in lib/seed.js:93

Gets the default list of module names that should be part of the seed files.

Returns:

Array:

list of modules in seed

getSeedUrls

(
  • customConfig
)
Array public

Defined in lib/seed.js:162

Build the list of urls to load the seed files for the app.

var scripts = app.yui.getSeedUrls();

As a result, scripts will be an array with one or more urls that you can use in your templates to provision YUI. Keep in mind that if use expressYUI.expose() middleware, you don't need to provision the seed, it will be provisioned automatically as part of the state object.

Parameters:

  • customConfig Object

    optional configuration to overrule filter and combine per request when building the urls. This is useful if you have a custom middleware to turn debug mode on, and combine off by passing some special parameter.

    • filter String

      optional filter to overrule any filter

    • combine Boolean

      optional flag to overrule combine, when set to false, it will avoid creating combo urls.

Returns:

Array:

the src url for each script tag that forms the seed

seed

(
  • modules
)
Function public chainable

Defined in lib/seed.js:134

Specify a list of modules to use as seed. This method extends the yui static configuration, specifically setting the app.yui.config().seed value.

app.yui.seed(["yui-base", "loader"]);

Parameters:

  • modules Array

    list of modules to use

Returns:

Function:

express middleware

Properties

CSS_FILTERS_MAP

Object

Defined in lib/seed.js:73

The default mapping for suffix based on the config filter value for css modules.

DEFAULT_FILTER

String

Defined in lib/seed.js:85

The default filter suffix for yui modules urls.

JS_FILTERS_MAP

Object

Defined in lib/seed.js:61

The default mapping for suffix based on the config filter value for js modules.