Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
acetate-folder
Advanced tools
Custom Nunjucks tag that iterates over all the files in a folder.
npm install acetate-folder --save
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.
I think there are a number of options you could make configurable inside the tag itself, like:
.
Pull requests are welcome! Just do your best to maintain the spaces, quotes, syntax, etc of the existing code and we should be good.
FAQs
Custom nunjucks tag that iterates over all the files in a folder
We found that acetate-folder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.