runk / connect-jade-static Goto Github PK
View Code? Open in Web Editor NEWConnect (ExpressJS) middleware for serving jade files as static html
Connect (ExpressJS) middleware for serving jade files as static html
Hi,
what do you think of this feature?
http://0.0.0.0:123/test/ should deliver the same result as
http://0.0.0.0:123/test/index.html if a index.jade template exists
I would write a pull request if you like
https://github.com/runk/connect-jade-static/blob/master/index.js#L54
I think it would make sense to perform a simple string operation here:
var urlpath = parsed.pathname.replace(/html$/, 'jade').replace(opts.baseUrl, '');
As far as I understood - the logic is to replace the string from the end. It can be achieved in more efficient ways :) I'll create a PR later
Hi,
I am using the latest version of connect-jade-static ( 0.1.5 ).
Unfortunately it is now sending 404 errors.
My usecase is that I have multiple middlewares e.g.
var express = require('express');
var app = express();
app.use(jadeStatic({
baseDir: publicDirectory,
baseUrl: baseUrl
}));
app.use(express.static(publicDirectory));
The public folder contains three files:
As there is no valid template for styles.css connect-jade-static returns 404 although the styles.css file exists and the connect-jade-static middle ware is not responsible.
Same thing happens for demo.html
Could you please call next() if you can't find a tpl for the request url?
It would be in https://github.com/runk/connect-jade-static/blob/master/index.js#L27
EDIT: It seems like connect-jade-static was an unused dependency of the project I'm looking at. Leaving this open in case it helps anyone with similar issues
For example, a new major release could be published that supported pug instead of jade, add .pug
to ext and allowedExt, and warn if files still end in .jade
the first time they get loaded.
The following patch seems to be the minimum needed to switch to pug (version is arbitrary). npm test
passes with that.
Or would you recommend another project - I'm not sure of the status of this repo
diff --git a/index.js b/index.js
index 927e648..1a2ddf8 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,6 @@
var path = require('path'),
fs = require('fs'),
- jade = require('jade'),
+ jade = require('pug'),
url = require('url'),
assert = require('assert');
diff --git a/package.json b/package.json
index e29229b..dee4cab 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
"compile"
],
"dependencies": {
- "jade": "*"
+ "pug": "^2.0.4"
},
"devDependencies": {
"mocha": ">=1.12.0"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.