SSI (Server Side Includes) Middleware for Connect and Express
npm install connect-ssi
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:
Using gulp-connect
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'
}));
{
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.