ejs-cli-extended
v0.1.1
Published
Extended EJS CLI tool with directory processing and watch functionality
Downloads
9
Maintainers
Readme
EJS CLI Extended
Extended EJS CLI tool with directory processing and watch functionality.
Features
- 🗂️ Directory Processing: Process all
.ejsfiles in a directory recursively - 👀 Watch Mode: Automatically recompile templates when files change
- ⚡ Concurrent Processing: Multiple templates can be processed simultaneously
- 🔄 100% Compatible: Directly executes the official EJS CLI, ensuring perfect compatibility
Installation
Global Installation
npm install -g ejs-cli-extendedLocal Installation
npm install ejs-cli-extendedWhen installed locally, you can run it with:
# Using npx
npx ejsc src:dist
# Using npm scripts
npm exec ejsc src:dist
# Or add to your package.json scripts
"scripts": {
"build": "ejsc src:dist"
}Usage
Single File Mode
Process a single EJS template file:
ejsc template.ejs -o output.html
ejsc template.ejs -f data.json -o output.htmlDirectory Mode
Process all .ejs files in a directory:
ejsc src:dist
ejsc templates:build -f config.jsonWatch Mode
Continuously watch for changes and recompile:
# Single file
ejsc template.ejs -o output.html --watch
# Directory
ejsc src:dist --watchOptions
Standard EJS CLI Options
All standard EJS CLI options are supported. For complete documentation, see the official EJS CLI repository.
Extended Options
--watch- Watch for changes and recompile automaticallyinput-dir:output-dir- Process directory (replaces single file path)
Examples
Basic Directory Processing
# Process all .ejs files in 'templates' directory
# Output to 'dist' directory
ejsc templates:distWith Data File
# Use JSON data file for template variables
ejsc src:build -f data.jsonWatch Mode
# Watch for changes and auto-recompile
ejsc templates:dist --watch -f config.jsonDirectory Structure
When using directory mode, the tool:
- Recursively finds all
.ejsfiles in the input directory - Maintains the same directory structure in the output
- Converts
.ejsextensions to.html - Creates output directories as needed
Example:
src/
├── index.ejs → dist/index.html
├── pages/
│ ├── about.ejs → dist/pages/about.html
│ └── contact.ejs → dist/pages/contact.html
└── components/
└── header.ejs → dist/components/header.htmlComplete EJS CLI Compatibility
This tool directly executes the official EJS CLI, ensuring 100% compatibility. All EJS CLI features are supported, including:
- All command-line options and flags
- Data input via files, command line, or stdin pipe
- Template preprocessing and compilation
- Custom delimiters and configurations
# All these work exactly like the official EJS CLI
ejsc template.ejs -o output.html
ejsc template.ejs -f data.json -o output.html
echo '{"name": "World"}' | ejsc template.ejs -o output.html
ejsc template.ejs -m $ -p [ -c ] -o output.htmlYou can use this tool as a complete drop-in replacement for the official EJS CLI.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
