Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

acetate-folder

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acetate-folder

Custom nunjucks tag that iterates over all the files in a folder

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Acetate Folder

Custom Nunjucks tag that iterates over all the files in a folder.

Install

npm install acetate-folder --save

Use

In your acetate config, which usually resides at acetate.conf.js add the following to initialize the folder tag:

var folder = require('acetate-folder');

function config(acetate) {
  acetate.use(folder());
}

module.exports = config;

Now, in your templates, you can use the folder tag, passing it a glob pattern:

{% folder './*.svg' %}
  <div class="FILENAME">FILENAME</div>
{% endfolder %}

This will iterate over every file from your current folder (relative to where the acetate config is) with an extension of .svg. By default the tag doesn't show files that begin with ..

The code inside the {% folder %} tag will be repeated for each file in the folder. Every occurrence of FILENAME will be replaced by the filename of each file.

For example, if you had the following directory located at /fruit-pics:

.hidden.svg
bananas.svg
apples.svg
fruit.svg
sub-directory/

And you used the following folder tag:

{% folder './fruit-pics/*.svg' %}
  <div class="FILENAME">FILENAME</div>
{% endfolder %}

You'd have the following html when you built your site with Acetate:

<div class="apples">apples</div>
<div class="bananas">bananas</div>
<div class="fruit">fruit</div>

These are returned in alphabetical order with filenames that start with a capital letter being before lowercase filenames.

TODO

I think there are a number of options you could make configurable inside the tag itself, like:

  • include directories
  • include files beginning with .
  • specify a sort order for results

Contributing

Pull requests are welcome! Just do your best to maintain the spaces, quotes, syntax, etc of the existing code and we should be good.

Keywords

FAQs

Package last updated on 05 Nov 2014

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc