Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules
102 changes: 53 additions & 49 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
# ejs-compile

Pre-compile [ejs](https://github.com/visionmedia/ejs) templates.

## Installation

```bash
$ npm install ejs-compile
```

## Usage

```
Usage: ejs-compile [file|dir] [options]

Options:

-h, --help output usage information
-V, --version output the version number
-w, --watch Watch file(s) for changes and re-compile
-o, --out [dir] Output to [dir] when passing files
--min Do some (unsafe) pre minification that minifiers usually can't do.
--debug
```

## License

(The MIT License)

Copyright (c) 2009-2010 Jonnathan Soares <jonnsl@hotmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ejs-compile

Pre-compile [ejs](https://github.com/visionmedia/ejs) templates.

## Installation

```bash
$ npm install ejs-compile
```

## Usage

```
Usage: ejs-compile [file|dir] [options]

Options:

-h, --help output usage information
-V, --version output the version number
-w, --watch Watch file(s) for changes and re-compile
-o, --out [dir] Output to [dir] when passing files.
--strict When set, generated function is in strict mode
--cache Compiled functions are cached
--usewith Whether or not to use with() {} constructs. If false then the locals will be stored in the locals object. Set to false in strict mode. Default false.
--rmWhitespace Remove all safe-to-remove whitespace, including leading and trailing whitespace. It also enables a safer version of -%> line slurping for all scriptlet tags (it does not strip new lines of tags in the middle of a line)
--min Do some (unsafe) pre minification that minifiers usually can't do.
--debug
```

## License

(The MIT License)

Copyright (c) 2009-2010 Jonnathan Soares <jonnsl@hotmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 13 additions & 6 deletions bin/ejs-compile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ program
.option('-w, --watch', 'Watch file(s) for changes and re-compile')
.option('-o, --out [dir]', 'Output to [dir] when passing files')
.option('--min', 'Do some (unsafe) pre minification that minifiers usually can\'t do.')
.option('--debug', '')
.option('--debug', 'Output generated function body')
.option('--strict', 'When set to true, generated function is in strict mode')
.option('--cache', 'Compiled functions are cached, requires filename')
.option('--usewith', 'Whether or not to use with() {} constructs. If false then the locals will be stored in the locals object. Set to false in strict mode.')
.option('--rmWhitespace', 'Remove all safe-to-remove whitespace, including leading and trailing whitespace. It also enables a safer version of -%> line slurping for all scriptlet tags (it does not strip new lines of tags in the middle of a line)')
.parse(process.argv);

var run = program.watch ? watch : compile;
Expand Down Expand Up @@ -81,16 +85,19 @@ function compile(file) {
if (err) return abort(err);

var contents = buf.toString('utf8');
var fn = ejs.compile(contents, {
//resolveInclude: false,
var options = {
client: true,
filename: path.join(process.cwd(), file),
compileDebug: program.debug === true,
filename: path.join(process.cwd(), file)
});
strict: program.strict === true,
cache: program.cache === true,
_with: program.usewith === true,
rmWhitespace: program.rmWhitespace === true,
}
var fn = ejs.compile(contents, options);

var data = fn.toString().split('\n');
data.splice(0, 1, data[0].replace(/^function anonymous/, 'module.exports = function '+ escape(basename)));
data.splice(2, 0, 'filters = filters || require(\'./filters.js\');');

if (program.out) {
fs.writeFile(
Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "ejs-compile",
"description": "Pre-compile ejs templates.",
"version": "0.0.1",
"author": {
"name": "Jonnathan Soares",
"email": "jonnsl@hotmail.com"
},
"dependencies": {
"commander": "*",
"read-dir-files": "*",
"ejs": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/jonnsl/ejs-compile"
},
"bin": {
"ejs-compile": "./bin/ejs-compile"
}
}
{
"name": "ejs-compile",
"description": "Pre-compile ejs templates.",
"version": "0.0.3",
"author": {
"name": "Jonnathan Soares",
"email": "jonnsl@hotmail.com"
},
"dependencies": {
"commander": "*",
"read-dir-files": "*",
"ejs": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/jonnsl/ejs-compile"
},
"bin": {
"ejs-compile": "./bin/ejs-compile"
}
}