Simple package for previewing ejs templates
Last updated a month ago by kuskoman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @est-normalis/ejs-preview 
SYNC missed versions from official npm registry.


Simple package for previewing ejs templates



As normal dependency:

yarn add @est-normalis/ejs-preview

or as dev dependency:

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


As normal dependency:

npm i @est-normalis/ejs-preview

or as dev dependency:

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


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'

    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


@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.



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


    "somekey": "somevalue"


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

result (html):



You can pass certain flags to the command:


Flag: -p, --port

Example: -p 997

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


Flag: -h, --host

Example: -h

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.


Flag: -m, --mime

Example: -m text/plain

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

Current Tags

  • 0.2.7                                ...           latest (a month ago)

10 Versions

  • 0.2.7                                ...           a month ago
  • 0.2.5                                ...           2 months ago
  • 0.2.1                                ...           6 months ago
  • 0.1.3                                ...           6 months ago
  • 0.1.2                                ...           6 months ago
  • 0.0.5                                ...           6 months ago
  • 0.0.4                                ...           6 months ago
  • 0.0.3                                ...           6 months ago
  • 0.0.2                                ...           6 months ago
  • 0.0.1                                ...           6 months ago
Maintainers (1)
Today 0
This Week 0
This Month 10
Last Day 0
Last Week 10
Last Month 13
Dependencies (2)
Dev Dependencies (6)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |