Skip to content

SSI (Server Side Includes) Middleware for connect

Notifications You must be signed in to change notification settings

uswitch/connect-ssi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

connect-ssi

SSI (Server Side Includes) Middleware for Connect and Express

Install

npm install connect-ssi

Examples

In your .shtml file

Uses node-ssi under the hood, supports all of the following:

<!--# include file="path" -->

<!--# set var="k" value="v" -->

<!--# echo var="n" default="default" -->

<!--# if expr="test" -->
<!--# elif expr="" -->
<!--# else -->
<!--# endif -->

Next, wire it up to Connect or Express like so:

gulp.task('connect', connect.server({
    root: ['app'],
    middleware: function() {
        return [connectSSI({
            baseDir: __dirname + '/app'
        })];
    }
}));

Using Express

var connectSSI = require('connect-ssi')
app.use(connectSSI({
    baseDir: __dirname + '/public'
}));

Using grunt-contrib-connect version 0.9.0 or greater

var connectSSI = require('connect-ssi');

and then inside the grunt.initConfig

connect: {
    options: {
        middleware: function(connect, options, middlewares) {
			if (!Array.isArray(options.base)) {
				options.base = [options.base];
			}
			var directory = options.directory || options.base[options.base.length - 1];

			middlewares.unshift(connectSSI({
				baseDir: directory,
				ext: '.html'
			}));                
            return middlewares;
        }
    }
}

Configuration

{
    ext: '.shtml', // file extension. Only urls ending in this will be evaluated.
    baseDir: __dirname // base path to look in for files
}

All config options are passed to node-ssi so,any additional options that it supports (such as payload) may be added to the configuration object.

About

SSI (Server Side Includes) Middleware for connect

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%