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

@flownet/lib-render-templates-dir

v0.1.14

Published

The **@flownet/lib-render-templates-dir** library is a utility project. It's developed around the principles of ease of use and efficiency in rendering multiple Nunjucks template files. The code is written in JavaScript and uses the Node.js platform.

Downloads

425

Readme

@flownet/lib-render-templates-dir

The @flownet/lib-render-templates-dir library is a utility project. It's developed around the principles of ease of use and efficiency in rendering multiple Nunjucks template files. The code is written in JavaScript and uses the Node.js platform.

The main purpose of this code is to render a directory of Nunjucks template files (*.njk extension) into regular HTML or other relevant formats. It accepts a directory of templates, an output directory and a context object, which specifies the data to be used in rendering the templates.

Functionality

  • The code first checks the existence of both the template directory and output directory. If the given directories don’t exist, it throws an error message.
  • The program then lists all template files in the given directory, considering any file pattern, primarily paying attention to files with the .njk extension.
  • For each template file, the program compiles it with the specified context and renders it into a normal HTML or other applicable file format.
  • Concurrent to this, the code checks for the precondition of overwriting existing files. If the rendered file is already present in the output directory, and overwriting isn't permitted, the program skips to the next file.
  • It then proceeds to write the rendered file to the output directory, creating any necessary directories in the output path.

For added functionality, the script also supports copying non-matching files directly to the output directory. If copyUnmatchedAlso is set to true, the code identifies files that were not matched as templates and copies them to the output directory, again respecting the overwrite policy.

In summary, this library provides end-users with an efficient way to render a directory of Nunjucks templates into another format such as HTML or copy non-matching files to an alternative directory. It also respects overwrite permissions to prevent unsolicited loss of pre-existing data.