Giter Site home page Giter Site logo

ejs2static's Introduction

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

ejs2static's People

Contributors

jbis9051 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.