Have ideas to improve npm?Join in the discussion! »

    This package has been deprecated

    Author message:

    jade-load will be unpublished soon, please use pug-loader

    jade-load

    0.0.4 • Public • Published

    jade-load

    The jade loader is responsible for loading the depenendencies of a given jade file. It adds fullPath and str properties to every Include and Extends node. It also adds an ast property to any Include nodes that are loading jade and any Extends nodes. It then recursively loads the dependencies of any of those included files.

    Build Status Dependency Status NPM version

    Installation

    npm install jade-load
    

    Usage

    var load = require('jade-load');

    load(ast, options)

    load.string(str, filename, options)

    load.file(filename, options)

    Loads all dependencies of the Jade AST. load.string and load.file are syntactic sugar that parses the string or file instead of you doing it yourself.

    options may contain the following properties:

    • lex (function): (required) the lexer used
    • parse (function): (required) the parser used
    • resolve (function): a function used to override load.resolve. Defaults to load.resolve.
    • read (function): a function used to override load.read. Defaults to load.read.
    • basedir (string): the base directory of absolute inclusion. This is required when absolute inclusion (file name starts with '/') is used. Defaults to undefined.

    The options object is passed to load.resolve and load.read, or equivalently options.resolve and options.read.

    load.resolve(filename, source, options)

    Callback used by jade-load to resolve the full path of an included or extended file given the path of the source file.

    filename is the included file. source is the name of the parent file that includes filename.

    This function is not meant to be called from outside of jade-load, but rather for you to override.

    load.read(filename, options)

    Callback used by jade-load to return the contents of a file.

    filename is the file to read.

    This function is not meant to be called from outside of jade-load, but rather for you to override.

    load.validateOptions(options)

    Callback used jade-load to ensure the options object is valid. If your overriden load.resolve or load.read uses a different options scheme, you will need to override this function as well.

    This function is not meant to be called from outside of jade-load, but rather for you to override.

    Example

    var fs = require('fs');
    var lex = require('jade-lexer');
    var parse = require('jade-parser');
    var load = require('jade-load');
     
    // you can do everything very manually
     
    var str = fs.readFileSync('bar.jade', 'utf8');
    var ast = load(parse(lex(str, 'bar.jade'), 'bar.jade'), {
      lex: lex,
      parse: parse,
      resolve: function (filename, source, options) {
        console.log('"' + filename + '" file requested from "' + source '".');
        return load.resolve(filename, source, options);
      }
    });
     
    // or you can do all that in just two steps
     
    var str = fs.readFileSync('bar.jade', 'utf8');
    var ast = load.string(str, 'bar.jade', {
      lex: lex,
      parse: parse,
      resolve: function (filename, source, options) {
        console.log('"' + filename + '" file requested from "' + source '".');
        return load.resolve(filename, source, options);
      }
    });
     
    // or you can do all that in only one step
     
    var ast = load.file('bar.jade', {
      lex: lex,
      parse: parse,
      resolve: function (filename, source, options) {
        console.log('"' + filename + '" file requested from "' + source '".');
        return load.resolve(filename, source, options);
      }
    });

    License

    MIT

    Keywords

    Install

    npm i jade-load

    DownloadsWeekly Downloads

    12

    Version

    0.0.4

    License

    MIT

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar