1.0.1 • Published 8 years ago

connect-preprocess v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

connect-preprocess

flexible preprocessor middleware for connect / express.

Installation

npm install connect-preprocess

Basic Use

var connect = require( 'connect' );
var Preprocessor = require( 'connect-preprocess' );
var engine = require( 'some-preprocessor-engine' );

var server = connect.createServer();
server.use( Preprocessor({ engine: engine }));

Options

ParameterTypeDescriptionDefault
acceptArrayFile types to preprocess[ 'html' , 'css' , 'js' ]
engineFunctionThe preprocessor enginefunction(str){return str}

Examples

grunt connect plugin

  • Gruntfile.js
    var Preprocessor = require( 'connect-preprocess' );
    
    grunt.initConfig({
      // ...
      connect: {
        options: { port: 9000 },
        server: {
          options: {
            middleware: function ( connect , options , middlewares ) {
              middlewares.unshift( Preprocessor({ engine: grunt.config.process }));
              return middlewares;
            }
          }
        }
      },
      // ...
    });
  • example.html
    <!DOCTYPE HTML>
    <html>
    <head>
        <title><%= pkg.name %></title>
        <script src="<%= pkg.main %>"></script>
    </head>
    <body>
        <a href="<%= pkg.homepage %>">visit the homepage!</a>
    </body>
    </html>
  • result
    <!DOCTYPE HTML>
    <html>
    <head>
        <title>connect-preprocess</title>
        <script src="index.js"></script>
    </head>
    <body>
        <a href="https://github.com/elnarddogg/connect-preprocess">visit the homepage!</a>
    </body>
    </html>
1.0.1

8 years ago

1.0.0

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.1

10 years ago