New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ejs2html

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ejs2html - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

24

cli.js

@@ -21,2 +21,3 @@ #! /usr/bin/env node

.arguments('<config> [dest]')
.option('-r, --read <variable_name>', 'Read contents from stdin, if available, and pipe to a given global variable name in the config.')
.action((config, dest) => {

@@ -43,4 +44,21 @@ options.config = config;

config.files.forEach(render);
if (!!program.read) {
process.stdin
.setEncoding('utf8')
.on('readable', () => {
let chunk = process.stdin.read();
config.globals[program.read] = config.globals[program.read] || '';
if (chunk !== null) {
config.globals[program.read] = [config.globals[program.read], chunk].join('');
} else {
run();
process.stdin.emit('end');
}
});
} else {
run();
}
/////////////////

@@ -144,2 +162,6 @@

function run() {
config.files.forEach(render);
}
/**

@@ -146,0 +168,0 @@ * Validates that a given config object for a file is valid

2

package.json
{
"name": "ejs2html",
"version": "1.0.4",
"version": "1.1.0",
"description": "A simple CLI for making HTML files from EJS templates.",

@@ -5,0 +5,0 @@ "main": "cli.js",

@@ -5,2 +5,4 @@ # ejs2html

Install:
```bash

@@ -10,10 +12,15 @@ npm i ejs2html -g

Usage:
```bash
Usage: ejs2html [options] <config> [dest]
ejs2html [options] <config> [dest]
```
Options:
Options:
-h, --help output usage information
-V, --version output the version number
```
-h, --help output usage information
-V, --version output the version number
-r, --read <variable_name> Read contents from stdin, if available, and pipe to a given global variable name in the config.
```

@@ -64,3 +71,80 @@ ## Config

## Reading stdin
Using the `-r, --read <var_name>` option allows you to receive piped data and set the data to a global variable that can be used in your templates. Without declaring this option, `ejs2html` will not do anything with the piped data.
So this will set a new global variable called `message` to the contents of `hello.txt`:
```bash
cat hello.txt | ejs2html config.json --read message
```
However, the piped data will be ignored in this example:
```bash
cat hello.txt | ejs2html config.json
```
### Example:
```bash
cat hello.txt | ejs2html config.json --read message
```
__"hello.txt"__
```
Hello world!
```
__"layout.js"__
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= title %></title>
</head>
<body>
<h1><%= title %></h1>
<p><%- message %></p>
</body>
</html>
```
__"config.json"__
```json
{
"files": [
{
"dest": "index.html",
"template": "layout",
}
],
"globals": {
"title": "My Site",
"message": ""
}
}
```
The result would be:
__"index.html"__
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Site</title>
</head>
<body>
<h1>My Site</h1>
<p>Hello world!</p>
</body>
</html>
```
## Examples

@@ -67,0 +151,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc