
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
cartero-express-middleware
Advanced tools
Express middleware for cartero. Overrides res.render with a method that accepts an additional argument, the path to a parcel.
res.locals.cartero_js
is populated with the script
tags for to load the js for the parcel.res.locals.cartero_css
is populated with the link
tags for to load the css for the parcel.The path of the parcel defaults to the directory of the view that is being rendered, so if you use your views folder to hold your parcels as recommended in the cartero docs and tutorial, the variables are set to the appropriate values for parcel of the view being rendered.
$ npm install cartero-express-middleware
After runnning cartero, initialize an instance of the cartero node hook, and then install the middleware, passing it the hook instance.
// app.js
var app = express();
var hook = require( "cartero-node-hook" );
var carteroMiddleware = require( "cartero-express-middleware" );
// ...
app.configure( function() {
app.set( "port" , process.env.PORT || 3000 );
app.set( "views" , path.join( __dirname, "views" ) );
app.use( express.static( path.join( __dirname, "static" ) ) );
// ...
var h = hook( // initialize a cartero hook
path.join( __dirname, "views" ), // views directory
path.join( __dirname, "static/assets" ), // output directory
{ outputDirUrl : 'assets/' } // output directory base url
);
app.use( carteroMiddleware( h ) ); // install the middleware
// ...
app.get( '/hello', function( req, res ) {
res.render( 'hello/hello.jade', {}, '/usr/parcels/hello' );
} );
} );
The middleware sets the res.locals.cartero_js
and res.locals.cartero_css
properties on res.locals
. Templates can then just dump cartero_js
and cartero_css
to load all the js / css assets they require.
doctype 5
html(lang="en")
head
title login
| !{cartero_js}
| !{cartero_css}
body
h1 People List
// ...
MIT
FAQs
Express middleware for Cartero.
We found that cartero-express-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.