https://github.com/pgilad/jade-globals
Detect which global variables are needed for your jade templates
https://github.com/pgilad/jade-globals
Last synced: about 1 year ago
JSON representation
Detect which global variables are needed for your jade templates
- Host: GitHub
- URL: https://github.com/pgilad/jade-globals
- Owner: pgilad
- License: mit
- Created: 2015-05-10T09:14:46.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-22T17:30:07.000Z (about 11 years ago)
- Last Synced: 2025-03-07T06:20:48.729Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 115 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jade-globals [](https://travis-ci.org/pgilad/jade-globals)
> Detect which global variables are needed for your jade templates
Given:
```jade
.some-class(title=externalTitle)
table#crazy-table(class=externalClass)
if showHeader
thead
```
Using `jade-globals` will output:
`['externalTitle', 'externalClass', 'showHeader']`
It's a tool meant to map your required dependencies in your jade files.
## Install
```sh
# install as a dev dependency
$ npm install --save-dev jade-globals
# install globally for use as cli
$ npm install --global jade-globals
```
## Usage
```js
var fs = require('fs');
var jadeGlobals = require('jade-globals');
var contents = fs.readFileSync('crazy-template.jade', 'utf8');
console.log(jadeGlobals(contents));
// => ['global1', 'global2']
```
Usage as a cli:
```sh
❯ jade-globals --help
Usage: jade-globals [options]
Detect which global variables are needed for your jade templates
Options:
-h, --help output usage information
-V, --version output the version number
-s, --show-jade-global Show the jade global as well
-i, --ignore Ignore keyword (default: [])
Examples:
$ jade-globals template.jade
$ jade-globals --ignore someGlobal template.jade
$ cat template.jade | jade-globals
```
## Options
### jadeGlobals(contents, params)
#### contents
`String` the contents of the jade file to parse.
**Required**
#### params
`Object` optional params and their defaults:
```js
{
// the `jade` global is hidden by default. Set to true to include it.
showJadeGlobal: false
// optional ignore list
ignore: []
}
```
## License
MIT © [Gilad Peleg](http://giladpeleg.com)