Socket
Book a DemoInstallSign in
Socket

ejs2static

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ejs2static

An extremely simple static site generator supporting ejs

2.0.3
latest
Source
npmnpm
Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

ejs2static

An extremely simple static site generator supporting ejs

Description

This module will generate static sites from ejs files. This allows you to deploy your site on a static provider such as GitHub pages.

I created this because I couldn't find a super simple module or CLI app to do it. Harp exists, but apparently Node 12 isn't supported.

Installation

Module

npm install ejs2static --save

Usage

const Generator = require('ejs2static');

const generator = new Generator(options);

gen.generate() // returns a Promise that resolves once all files are generated

options(optional)

  • sourceDir - This directory will be searched recursively for files. EJS files will be rendered to HTML and copied to the outputDur retaining the directory structure.
  • outputDir - Generates to the static site to this directory.This directory will be cleared before generation if empty option is true!
  • copyAll (optional - default false) - If true, all non ejs files in the sourceDir will be copied to the buildDir. This is helpful for copying assets.
  • data - (optional - default {}) - Object with keys of files relative to the sourceDir and values of an object that will be passed as data to the ejs render when the file specified in the key is rendered. (Huh? Check the examples).
  • empty - (optional - default false) - If true, the outputDir will be cleared before render.

Example

├── dist
│   ├── components
│   │   └── head.html
│   ├── dir
│   │   └── dirtest.html
│   ├── test-file.txt
│   └── test.html
├── ejs
│   ├── components
│   │   └── head.ejs
│   ├── dir
│   │   └── dirtest.ejs
│   ├── test-file.txt
│   └── test.ejs
└── test.js

// test.js
const Generator = require('../ejs2static');

const gen = new Generator({
    sourceDir: './ejs',
    outputDir: './dist',
    copyAll: true,
    data: {
        './dir/dirtest.ejs': {
            someData: "testing data"
        }
    }
});

gen.generate().then(_ => console.log("Done!"));

License

MIT

FAQs

Package last updated on 03 Mar 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.