Giter VIP home page Giter VIP logo

ejs-cli's Introduction

ejs-cli

ejs compile client.

install

from npm

npm -g install ejs-cli

from github

git clone git://github.com/fnobi/ejs-cli.git

usage

Options:
  -h, --help      show this help.                               [boolean]  [default: false]
  -f, --file      give ejs template file path.                  [string]
  -b, --base-dir  base directory that -f is relative to.        [string]  [default: "./"]
  -e, --exclude   file/directory names to exclude               [string] [space separated if more than one]
  -o, --out       file to write compiled.                       [string]
  -O, --options   option variables (file path or JSON string).  [string]

examples

ejs-cli "*.ejs" --out dest/ --options options.json
# renders the *.ejs files in the current working directory and outputs compiled files to dest/
ejs-cli --base-dir src/ "*.ejs" --out dest/
# renders the *.ejs files in src/ and outputs compiled files to dest/
ejs-cli --base-dir src/ "**/*.ejs" --out dest/
# renders the *.ejs files in src/ and its subdirectories and outputs compiled files to dest/

Make sure to quote the file pattern, otherwise, your shell will expand it before it is passed to ejs-cli. This behaviour would prevent ejs-cli from walking down the tree in this latest exemple.

ejs-cli --base-dir src/ "**/*.ejs" --exclude "partials/" --out dest/
# exclude any "partials" directory from rendering
cat example.ejs | ejs-cli example.ejs > example.html

ejs-cli's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ejs-cli's Issues

Empty tests

This is not a test of EJS cli:

var expect = require('chai').expect;

describe('node.js', function () {
    it('calculate addition', function () {
        expect(3 + 2).to.be.equal(5);
    });
});

Vulnerability in optimist: consider replacing

I'm getting a dependabot alert for minimist < 0.2.1: CVE-2020-7598.

Currently, ejs-cli depends on optimist 0.6.1, which depends on minimist 0.0.10.

Optimist appears to have been abandoned, and has a deprecation notice directing users to yargs or nomnom.

You may want to consider replacing optimist with yargs. While it's not a trivial change, it doesn't look too complex โ€” I made an attempt on a fork of this repository, but ejs-cli has stopped working in my project, so I can't test it properly.

crash when use --exclude

It crash here :

node_modules/optimist/node_modules/minimist/index.js:49
setKey(argv, x.split('.'), value);

isn't it linked to the w and not e here :
https://github.com/fnobi/ejs-cli/blob/master/lib/cli.js#L32

i've changed it but it don't fix, but i don't understande why it fail here...

here is my full command :

ejs-cli --base-dir content/common/ *.ejs --exclude mainTemplate.ejs sitemap.xml.ejs --options generated/config.common.json --out generated/toPublish/

but it also fail with :

ejs-cli --base-dir content/common/ "*.ejs" --exclude mainTemplate.ejs --options generated/config.common.json --out generated/toPublish/

I really don't understand where is the problem.

EJS Dependency

The package.json lists EJS v0.8.5 as a dependency.

Work at tj/ejs has stalled, and EJS version 2 is now being actively developed at mde/ejs (where I am a collaborator).

The API should be compatible, however, the EJS syntax has changed some. Most notably, the filters feature has been removed.

See the CHANGELOG for a complete list of changes.

Would you consider upgrading the dependency to EJS v2.4.1?

Feature request - Add option to pass data parameter?

Currently it looks like ejs-cli only wraps the call to ejs.renderFile() with the signature renderFile(filename, options, callback) - and there is no way to pass in a data parameter when rendering a template with ejs-cli.

It would be great to see this feature added. Currently I need to write a helper script that wraps ejs just so I can render a template from the shell with the data parameter.

Please upgrade minimatch version

$ snyk test ejs-cli
(node:8236) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.

Testing ejs-cli...

โœ— High severity vulnerability found in minimatch
Description: Regular Expression Denial of Service (DoS)
Info: https://snyk.io/vuln/npm:minimatch:20160620
Introduced through: [email protected]
From: [email protected] > [email protected]

Organization: ainthek
Package manager: npm
Open source: yes
Project path: ejs-cli

Tested ejs-cli for known vulnerabilities, found 1 vulnerability, 1 vulnerable path.

Absolute paths broken with -f

Please handle -f absolute paths properly when -b is omitted, so that this command line application behaves more like conventional command line applications.

Program should use different Exit Status when it finds an error

I wanted to use this tool to corroborate my EJS as a validator before deploying the files and actually using them, but it always returns an exit code of 0 regardless if it found or not errors while compiling the EJS's.

I tried this out by:

$>ejs-cli MyFileName
{ReferenceError:....}
$>echo Exit Code is %errorlevel%
Exit Code is 0

It would be grate if the Exit code would represent the real exit status of the application.

I really liked this tool otherwise,
Thanks for your time and effort.

Discussion: Directory Structures

Perhaps I'm just missing something, but it seems a bit difficult to use ejs-cli with some directory structures.

Given the following project tree:

/
  src
    partials
        footer.ejs
    index.ejs
    page1.ejs
  dist
    index.html
    page1.html
  package.json

Where the .ejs files in partials/ are included by the files in src/:

How would you render all the files in src/ (but not the ones in partials/) and output them to dist/ when calling ejs-cli from an npm script in the project root?

ejs-cli src/*.ejs --out dist/ tries to output the files to dist/src/*.ejs. Right now I'm using cd src && ejs-cli *.ejs --out ../dist/, but it seems to me there should be a better way.

Adding to our example, suppose we add a subfolder to src/ named archives/. We want to render the files in archives/, but not the files in partials or archives/partials. How would we accomplish that?

/
  src
    partials
        footer.ejs
    archives
      partials
        oldfooter.ejs
      oldpage1.ejs
    index.ejs
    page1.ejs
  dist
    archives
      oldpage.html
    index.html
    page1.html
  package.json

I can't think of any good ways to do it.

I like this project, but I would like to see it even better!

Multiple options ?

I'm trying to use ejs-cli with multiple options file, I tried various syntax but it doesn't seem to work.

For example:
ejs-cli story.ejs -O locales/en/story.json -O locales/en/main.json
gives the following error:

[Error: fail to parse options JSON.
 => locales/en/story.json,locales/en/main.json]

From what I understand, the program puts the file path in an array then tries to JSON.parse it like it would with a string.

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.