Giter Club home page Giter Club logo

pipemaker's Introduction

Pipemaker

Powerful chaining of pre- and post-processors, with dynamic dependency downloading.

Installation

$ npm install pipemaker

Examples

var pipemaker = new Pipemaker();

// Simple pipelines (extension, name)
pipemaker.addPipeline("jade");
pipemaker.addPipeline("coffee");
pipemaker.addPipeline("js", "dust");

// Chained pipelines (extension, chain)
pipemaker.addPipeline("css", "css>clean-css");
pipemaker.addPipeline("js", "javascript>uglify-js");
pipemaker.addPipeline("jbs", "jade>handlebars");

function next(err, compiled) { console.log(compiled); }

// Compile
pipemaker.compile("coffee", "console.log 'Hello'", next);
pipemaker.compile("handlebars", "Hello {{ name }}", { name : "Donald" }, next);
pipemaker.compileFile("./path-to/file.coffee", next);

API

PipemakerPipemaker .addPipeline(ext, [chain])function .compile(ext, str, [options], next) .compileBlock(lines, lineNo, [options], next) .compileFile(filename, [options], next) .compileWildcard(str, [options], next) .createPipeline(chain)function .getPipeline(chain)function .hasPipeline(ext)Boolean .removePipeline(ext)

Pipemaker ⇒ Pipemaker

Constructor for Pipemaker class. Automatically installs packages by default.

Returns: Pipemaker - Instance of class.

Param Type Description
mappings Object Keys correspond to extensions, values to pipeline names.
options Object Install directory dir, and whether to fetch if missing.

Example

var pipemaker = new Pipemaker({ dir : process.cwd() });

pipemaker.compile(ext, str, [options], next)

compiles a string using pipeline associated with ext

Param Type Default Description
ext String The extension associated with string (e.g. "coffee").
str String The string to be compiled.
[options] Object {} Options to be passed to rendering pipeline.
next function Callback of type fn(err, compiled).

Example

pipemaker.compile("coffee", "console.log 'Hello'", function(err, compiled) {
    console.log(compiled);
    // => console.log('Hello');
  });

pipemaker.compileFile(filename, [options], next)

compiles a file using pipeline associated with file's extension

Param Type Default Description
filename String Name of file.
[options] Object {} Options to be passed to rendering pipeline.
next function Callback of type fn(err, compiled).

Example

pipemaker.compileFile("app.coffee", function(err, compiled) {
    // Compiled version of app.coffee
  });

pipemaker.compileWildcard(str, [options], next)

Compiles a wildcard string.

Param Type Default Description
str String The string to be compiled.
[options] Object {} Options to be passed to rendering pipeline.
next function Callback of type fn(err, compiled).

pipemaker.compileBlock(lines, lineNo, [options], next)

Recursively compiles a wildcard block.

Param Type Default Description
lines Array The lines to be compiled
lineNo Number The line number to start with
[options] Object {} Options to be passed to rendering pipeline
next function Callback of type fn(err, compiled, numberOfLinesProcessed)

pipemaker.createPipeline(chain) ⇒ function

Returns a compilation function based on input chain.

Returns: function - Compilation function fn(str, options, next).

Param Type Description
chain String String containing names of pipelines to use.

Example

pipemaker.createPipeline("jade");
  pipemaker.createPipeline("jade>handlebars");
  pipemaker.createPipeline("js>uglify-js");

pipemaker.getPipeline(chain) ⇒ function

Gets an pipeline based on chain, creating pipeline if necessary.

Returns: function - Compilation function fn(str, options, next).

Param Type Description
chain String Chain of pipelines.

Example

pipemaker.getPipeline("jade>handlebars");

pipemaker.addPipeline(ext, [chain]) ⇒ function

Adds an pipeline for an extension, creating pipeline if necessary.

Returns: function - Compilation function fn(str, options, next).

Param Type Description
ext String File extension to be associated with pipeline.
[chain] String Optional chain for creating pipeline.

pipemaker.removePipeline(ext)

Removes an pipeline by extension.

Param Type Description
ext String File extension to for removal.

pipemaker.hasPipeline(ext) ⇒ Boolean

Determines if an pipeline currently exists for an extension.

Returns: Boolean - Whether pipeline exists.

Param Type Description
ext String File extension to check.

License

MIT

pipemaker's People

Contributors

brandoncarl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.