New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jade-client-connect

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jade-client-connect - npm Package Compare versions

Comparing version

to
0.0.2

39

lib/jade-connect.js
(function() {
var fs, jade, path;
var compile, fs, jade, opts, path, source, templates, watch;
fs = require("fs");
jade = require("jade");
path = require("path");
module.exports = function(options) {
var ns, re, src, templates, url;
watch = require("watch");
templates = "";
source = "";
opts = {};
compile = function(src, options) {
var ns;
if (src == null) {
src = source;
}
if (options == null) {
options = {};
options = opts;
}
src = options.src || "views";
ns = options.ns || "tpl";
if (src.charAt(0) === "/") {
src = src.slice(1, src.length);
}
templates = "window." + ns + " = {};";
fs.readdir(src, function(err, files) {
if (!err) {
if (err) {
return console.log(err);
} else {
return files.forEach(function(file) {

@@ -33,4 +38,20 @@ var filename, fn, nm, tpl;

});
return templates;
};
module.exports = function(src, options) {
var re, url;
if (options == null) {
options = {};
}
if (!src) {
throw new Error("Source directory not included");
}
templates = compile(src, options);
source = src;
opts = options;
url = options.url || "templates.js";
re = new RegExp(".*" + url + "$");
watch.watchTree(src, function() {
return compile();
});
return function(req, res, next) {

@@ -37,0 +58,0 @@ if (re.test(req.url)) {

{
"name": "jade-client-connect",
"description": "Jade Client Connect - A compiler to help use templates on a web client",
"version": "0.0.1",
"version": "0.0.2",
"author": "Ed Siok <@sioked>",
"main": "./lib/index.js",
"repository": {
"type": "git",
"url" : "http://github.com/sioked/jade-client-connect.git"
},
"dependencies": {
"uglify-js" : "1.0.7",
"jade" : "0.15.4"
"jade" : "0.15.4",
"watch" : "0.3.2"
},

@@ -15,4 +19,5 @@ "devDependencies": {

"nodeunit": "0.5.1",
"request" : "2.1.1"
"request" : "2.1.1",
"rimraf" : "latest"
}
}

@@ -15,3 +15,3 @@ #Jade Client Connect

app = require('connect').createServer();
app.use(require('./jade-client-connect/')());
app.use(require('./jade-client-connect/')(__dirname + "/views"));
```

@@ -30,10 +30,8 @@

var options = {
src : 'views',
ns : 'tpl'
}
app.use(require('./jade-client-connect/')(options));
app.use(require('./jade-client-connect/')(__dirname+"/views", options));
```
The src option is the folder that contains all of the jade templates.
This should be relative to your currently running application. Each of
The src option is the folder that contains all of the jade templates. Each of
the files inside this directory will be compiled as a javascript jade

@@ -40,0 +38,0 @@ template in the ns client namespace. By default the namespace is tpl so

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet