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

asparagus

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asparagus - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

.travis.yml

6

index.js
'use strict';
var Promise = require('bluebird'),
fs = Promise.promisifyAll(require('fs')),
var _Promise = require('bluebird'),
fs = _Promise.promisifyAll(require('fs')),
pathUtil = require('path'),

@@ -49,3 +49,3 @@ join = pathUtil.join,

function promise(filename) {
return new Promise(function (resolve) {
return new _Promise(function (resolve) {
if (Object.keys(sources).length >= 2) {

@@ -52,0 +52,0 @@ return Object.keys(sources).map(function (id) {

@@ -11,10 +11,11 @@ 'use strict';

module.exports = Compiler = function Compiler(paths, options) {
function pathException(paths) {
if ((!paths || !paths.jsPath) || (!paths || !paths.tmplPath)) {
throw new Error('jsPath and tmplPath are required arguments');
}
this.paths = paths;
}
options = options || {};
this.next = options.next || function (err) {
function nextFunction(options) {
// if next not defined throw on err
return options.next || function (err) {
if (err) {

@@ -24,3 +25,12 @@ throw new Error(err);

};
// to allow absolute include paths
}
module.exports = Compiler = function Compiler(paths, options) {
pathException(paths);
this.paths = paths;
options = options || {};
this.next = nextFunction(options);
// to allow absolute include paths defined basedir
this.basedir = options.basedir || pathUtil.dirname(this.paths.tmplPath);

@@ -42,3 +52,5 @@ this.namespace = options.namespace || 'templates';

getNamespaceStr: function getStartStr() {
return 'window.' + this.namespace + ' = window.' + this.namespace + ' || {}; \n' + 'window.' + this.namespace + '.';
return 'window.' + this.namespace + ' = window.' +
this.namespace + ' || {}; \n' + 'window.' +
this.namespace + '.';
},

@@ -45,0 +57,0 @@

{
"name": "asparagus",
"version": "0.0.1",
"version": "0.0.2",
"description": "Flexible template compiler",
"keywords": [ "jade", "template", "node", "build", "tool", "gulp", "compile" ],
"keywords": [
"jade",
"template",
"node",
"build",
"tool",
"gulp",
"compile"
],
"author": "Joseph Chapman",
"email": "joe@creatify.com",
"license": "MIT",
"bin": {
"asparagus": "bin/asparagus"
},
"scripts": {

@@ -10,0 +21,0 @@ "unit": "node ./node_modules/mocha/bin/mocha test/",

asparagus
=========
*Template compiling build tool for NodeJS*
Template compile tool for NodeJS.
Compile all or some of your templates, even those in parallel sub-folders, to a location that may or may not yet exist.
Plays nice with Gulp
[![Build Status](https://travis-ci.org/JoeChapman/asparagus.svg?branch=master)](https://travis-ci.org/JoeChapman/asparagus)
[![NPM version](https://badge.fury.io/js/asparagus.svg)](http://badge.fury.io/js/asparagus)
### Install globally
### Install globally to use the binary commmands

@@ -14,9 +16,71 @@ ```

adds a binary to the path so you can compile from the command line
adds a binary to the path so you can run *asparagus* from the command line
#### Command line
```
$ asparagus '/path/to/source/folder'
$ asparagus /path/to/source/folder namespace=mytemplates format=camelcase
```
#### JavaScript
```
var asparagus = require('aspargus');
// A source parameter is required as the first argument to asparagus
asparagus(__dirname + '/views', {
dest: __dirname + '/public/templates',
format: 'camelcase',
namespace: 'partials',
basedir: __dirname + '/views/dev',
exclusive: 'includes'
```
**Plays nice with Gulp too** simply wrap the above in a gulp task, I.e.,
```
var gulp = require('gulp'),
asparagus = require('asparagus');
gulp.task('asparagus', function () {
asparagus(__dirname + '/views', {
dest: __dirname + '/public/templates',
format: 'camelcase',
namespace: 'partials',
basedir: __dirname + '/views/dev',
exclusive: 'includes'
});
```
#### Browser
Templates are added to the namespace by the function name corresponding to their filename.
If you are using [Jade](http://jade-lang.com/), you'll need to include [Jade Runtime](https://raw.githubusercontent.com/visionmedia/jade/master/runtime.js) in the browser.
```
window.partials = {
functionName: function () { ..... }
};
```
### Options
```
[dest] {String}
- The final intended destination of the compiled templates(s), defaults to the value of the source parameter.
[format] {String}
- The format of each compiled template function name in the namespace, defaults to 'underscore' delimited function names.
[namespace] {String}
- The namespace object on the `window` object that will store references to the compiled template functions, defaults to 'templates'.
[basedir] {String}
- allows for absolute include paths, defaults to the value of the source parameter.
[exclusive] {String}
- When set to an existing directory name in the source path, compiles files only from and to that directory name within source and dest paths.
```
### Explained

@@ -65,36 +129,1 @@

Any absolute include statements within any of the original templates will be appended to the basedir option, __dirname + '/views/dev'.
#### JavaScript
```
var asparagus = require('aspargus');
// A source parameter is required as the first argument to asparagus
asparagus(__dirname + '/views', {
dest: __dirname + '/public/templates',
format: 'camelcase',
namespace: 'partials',
basedir: __dirname + '/views/dev',
exclusive: 'includes'
});
```
### Options
```
[dest] {String}
- The final intended destination of the compiled templates(s), defaults to the value of the source parameter.
[format] {String}
- The format of each compiled template function name in the namespace, defaults to 'underscore' delimited function names.
[namespace] {String}
- The namespace object on the `window` object that will store references to the compiled template functions, defaults to 'templates'.
[basedir] {String}
- allows for absolute include paths, defaults to the value of the source parameter.
[exclusive] {String}
- When set to an existing directory name in the source path, compiles files only from and to that directory name within source and dest paths.
```

@@ -115,5 +115,5 @@ 'use strict';

compiler = Compiler.create({
jsPath: '/javascript/path',
tmplPath: '/template/path'
}, options);
jsPath: '/javascript/path',
tmplPath: '/template/path'
}, options);
});

@@ -140,7 +140,7 @@

compiler = Compiler.create({
jsPath: '/javascript/path',
tmplPath: '/template/path'
}, {
format: 'unsupported'
});
jsPath: '/javascript/path',
tmplPath: '/template/path'
}, {
format: 'unsupported'
});

@@ -147,0 +147,0 @@ compiler.format

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc