npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

edgejs-cli

v1.1.1

Published

CLI utility to generate files based on edge templates

Downloads

27

Readme

edgejs-cli

:warning: Maturity Level: Alpha

Minimal CLI utility to generate files using edge.js templates

Usage

pnpm i -g edgejs-cli
# ^ Will add an edget utility to PATH

# Render a single template
edget -i templates/home.edge -o site
# ^ Generates site/home.html by rendering home.edge

# Pass data to templates through a JSON/YAML file
edget -i templates/home.edge -o site -d data.json
# ^ Same as above but home.edge can use any values defined in data.json

# Render all templates within a directory (Files prefixed with . or _ are ignored)
edget -i templates -o site -d data.json

# Skip escaping if generating non-html content
edget -i sql-templates -o sql --skipEscaping

Advanced features

Multi-mode

It is not necessary that each input file generate exactly one input file, or that the output file name match input file name.

With multi-mode, we can render an output in the following format (inspired by Vue SFC):

<!-- post.multi.edge -->
<file path="post/summary.html">
Here is some summary content
</file>
<file path="post/details.html">
Here are some details
</file>

Note that the file extension needs to be .multi.edge.

This will generate two files <out-dir>/post/summary.html with content Here is some summary content and <out-dir>/post.details.html with content Here are some details.

XML parsing happens after the edge template has been rendered, so not only can the content inside <file> tags be dynamic, we can also dynamically add <file> tags too.

So the following is legal:

@each (post in posts)
<file path="post/{{post.slug}}/summary.html">
{{post.title}} - by {{post.author}}
</file>
<file path="post/{{post.slug}}/details.html">
{{post.body}}
</file>
@end

(final output must be valid XML)

It is possible to dedent and trim the content through attributes in the file tag:

<file path="post/summary.html" trim="true" dedent="true">
</file>

Use cases

This is intended to be a minimal utility that simplifies tasks like below for JS/TS developers comfortable with CLI:

  • Building static sites
  • Knowledge-graphs
  • Code generation
  • Using edge.js from other languages

Motivations

If you don't care about cross-language support, edgejs is easier than Handlebars/mustache/liquid etc. because the embedded expressions are plain JS - so there is less need to learn custom syntax specific to the templating language, and we also have first class support for async.

Also, unlike JSX based solutions, it is more versatile because it is not limited to HTML


:warning: This project has nothing to do with Microsoft edge browser.