Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/betahuhn/ejs-serve
🔨👀 Build, watch and serve your EJS templates in your browser.
https://github.com/betahuhn/ejs-serve
build-tool development ejs ejs-cli ejs-template-engine ejs-templates http reload watch
Last synced: 3 months ago
JSON representation
🔨👀 Build, watch and serve your EJS templates in your browser.
- Host: GitHub
- URL: https://github.com/betahuhn/ejs-serve
- Owner: BetaHuhn
- License: mit
- Created: 2020-10-30T23:20:17.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T12:59:02.000Z (almost 2 years ago)
- Last Synced: 2024-09-28T07:22:28.711Z (3 months ago)
- Topics: build-tool, development, ejs, ejs-cli, ejs-template-engine, ejs-templates, http, reload, watch
- Language: JavaScript
- Homepage: https://mxis.ch
- Size: 591 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# ejs-serve
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/BetaHuhn/ejs-serve/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/ejs-serve)](https://www.npmjs.com/package/ejs-serve)
Build, watch and serve your EJS templates in your browser.
## 👋 Introduction
[ejs-serve](https://github.com/BetaHuhn/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](#generate-email-with-mjml)## 🚀 Get started
Install [ejs-serve](https://github.com/BetaHuhn/ejs-serve) globally via npm:
```shell
npm install ejs-serve -g
```After that `ejs-serve` is ready to be used 🎉
## 📚 Usage
```shell
Usage: ejs-serve -f -d -pBuild, watch and serve your EJS templates in your browser.
Options:
-f, --file path to ejs file
-d, --data JSON string or path to json file
-p, --port 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
```## 🛠️ Examples
### Render EJS template with data from JSON file and serve it
```shell
ejs-serve -f index.ejs -d data.json
```### Render EJS template with data from JSON string and serve it
```shell
ejs-serve -f index.ejs -d '{"message":"Hello World!"}'
```### Serve on custom port
```shell
ejs-serve -f index.ejs -d data.json -p 3000
```### Automatically open browser
`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.
```shell
ejs-serve -f index.ejs -d data.json -p 3000 -o
```### Generate email with mjml
`ejs-serve` can be used in conjunction with [mjml](https://github.com/mjmlio/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.
```shell
ejs-serve -f index.ejs -d data.json -e
```### Use it in another project
If you want to use `ejs-serve` for development in another project, add it to your dev dependencies:
```shell
npm install ejs-serve --save-dev
```And include this command in your `package.json`
```json
"scripts": {
"templates": "ejs-serve -f ./path/to/file.ejs -d '{\"message\":\"Hello!\"}'"
},
```## 📝 To do
Here is what's currently planned for [ejs-serve](https://github.com/BetaHuhn/ejs-serve):
- render multiple files/whole directory
- render files and output them to directory## 💻 Development
Issues and PRs are very welcome!
- run `yarn lint` or `npm run lint` to use eslint.
- run `yarn example` or `npm run example` to serve the example EJS filePlease check out the [contributing guide](CONTRIBUTING.md) before you start.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). To see differences with previous versions refer to the [CHANGELOG](CHANGELOG.md).
## ❔ About
This library was developed by me ([@betahuhn](https://github.com/BetaHuhn)) in my free time. If you want to support me:
[![Donate via PayPal](https://img.shields.io/badge/paypal-donate-009cde.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=394RTSBEEEFEE)
## License
Copyright 2020 Maximilian Schiller
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.