ejs-serve is a CLI tool for developing/working with EJS templates.
- renders your EJS templates with data
- serves the files to your browser
- watches for file changes and reloads your browser automatically
- no extra files in your working directory
- also watches for changes in your data
- can be used in conjunction with mjml
Install ejs-serve globally via npm:
npm install ejs-serve -g
After that ejs-serve
is ready to be used π
Usage: ejs-serve -f <filename> -d <json string|file> -p <port>
Build, watch and serve your EJS templates in your browser.
Options:
-f, --file <path> path to ejs file
-d, --data <json> JSON string or path to json file
-p, --port <number> port on which to serve the file (default: 8080)
-e, --email [boolean] render file with mjml (default: false)
-o, --open [local/network] open file in browser automatically (default: false)
-v, --version output the version number
-h, --help display help for command
ejs-serve -f index.ejs -d data.json
ejs-serve -f index.ejs -d '{"message":"Hello World!"}'
ejs-serve -f index.ejs -d data.json -p 3000
ejs-serve
can automatically open the file in the browser. If you use -o
it will open the file via its local address (localhost:port). You can use -o network
to use the network address.
ejs-serve -f index.ejs -d data.json -p 3000 -o
ejs-serve
can be used in conjunction with mjml to render your ejs file with data and generate a reponsive email. Use the -e
option to enable this feature and it will run the rendered ejs file through mjml.
ejs-serve -f index.ejs -d data.json -e
If you want to use ejs-serve
for development in another project, add it to your dev dependencies:
npm install ejs-serve --save-dev
And include this command in your package.json
"scripts": {
"templates": "ejs-serve -f ./path/to/file.ejs -d '{\"message\":\"Hello!\"}'"
},
Here is what's currently planned for ejs-serve:
- render multiple files/whole directory
- render files and output them to directory
Issues and PRs are very welcome!
- run
yarn lint
ornpm run lint
to use eslint. - run
yarn example
ornpm run example
to serve the example EJS file
Please check out the contributing guide before you start.
This project adheres to Semantic Versioning. To see differences with previous versions refer to the CHANGELOG.
This library was developed by me (@betahuhn) in my free time. If you want to support me:
Copyright 2020 Maximilian Schiller
This project is licensed under the MIT License - see the LICENSE file for details.