New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@est-normalis/ejs-preview

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@est-normalis/ejs-preview

Simple package for previewing ejs templates

latest
Source
npmnpm
Version
0.2.7
Version published
Weekly downloads
5
150%
Maintainers
1
Weekly downloads
 
Created
Source

ejs-preview

Simple package for previewing ejs templates

Installation

Yarn

As normal dependency:

yarn add @est-normalis/ejs-preview

or as dev dependency:

yarn add -D @est-normalis/ejs-preview

npm

As normal dependency:

npm i @est-normalis/ejs-preview

or as dev dependency:

npm i @est-normalis/ejs-preview --save-dev

Usage

As normal library

@est-normalis/ejs-preview exports by default function allowing to start webserver and serve choosen ejs file.

import { previewTemplate } from '@est-normalis/ejs-preview'

previewTemplate({
    templatePath: 'src/templates/index.html.ejs'
})

The function takes object specified in PreviewConfig interface as argument.

Aviable options:

templatePath: string
variables?: any
url?: string
port?: any
mimeType?: string

As CLI

@est-normalis/ejs-prewiev has a command line interface. It allows you to create preview server without creating unneccessary boilerplate files.

The cli is aviables when you simply type package name in shell.

@est-normalis/ejs-prewiev <templatePath>

The command takes two positional arguments. The first one is obligatory and takes a path to template.

@est-normalis/ejs-prewiev index.html.ejs

The second one is optional and takes path to JSON file with variables required by template. If not passed variables passed to template are equal to empty object ({}).

@est-normalis/ejs-prewiev index.html.ejs variables.json

If your file has .json extension you can ommit it when typing its path, however if there is another file mathing name without extension it will be required and parsed.

Example

index.html.ejs:

<p><%= somekey %></p>

variables.json:

{
    "somekey": "somevalue"
}

command:

@est-normalis/ejs-prewiev index.html.ejs variables

result (html):

<p>somevalue</p>

Flags

You can pass certain flags to the command:

Port

Flag: -p, --port

Example: -p 997

Result: Page will be aviable under localhost:997 instead of default localhost:9999.

host

Flag: -h, --host

Example: -h 10.0.2.15

Result: Server url will be changed to the new one. Its especially useful when you for example want to preview template on virtual machine on its internal network.

mime

Flag: -m, --mime

Example: -m text/plain

Result: Changes default Content-Type header from text/html to- in this case- text/plain.

Keywords

ejs

FAQs

Package last updated on 19 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts