More Dynamic templates
Generic Nunjucks, Twig and Liquid templates for 11ty/Build Awesome, Grav, Drupal, Jekyll, Shopify, etc.
There are 2 ways to get started:
A. Install with NPM #
npm install @anyblades/blades
cd _includes # or where your includes dir is
ln -s ../node_modules/@anyblades/blades/_includes/blades
That's it! Now you can reuse templates from Blades like this:
{% extends 'blades/NAME.njk' %}
{% include 'blades/NAME.njk' %}
{% include blades/NAME.liquid %}
{% render blades/NAME %}
B. Starter projects #
subtle.blades.ninja 11ty micro-starter
start.11ty.blades.ninja 7-in-1 starter (including Tailwind)
jekyll.blades.ninja starter
Appendix Supported template engines #
Nunjucks .njk #
Official docs:
Syntax highlighting #
-
Install
ginfuru.better-nunjucks=/edheltzel/better-nunjucks-for-visual-studio-code
-
Set it as default formatter
This is a modern fork of the original extension. It is specifically designed to solve the "11ty problem" where you mix Nunjucks and HTML.
Why it's better: It injects Nunjucks grammar directly into the standard HTML grammar. This means you get full Nunjucks highlighting and the editor still knows it's an HTML file, giving you better Emmet and CSS autocompletion.
No Config: It works out of the box without needing to manually map file associations in your settings.
Auto-formatting #
-
Install
esbenp.prettier-vscode=/prettier/prettier-vscode
-
Install a compatible Prettier plugin for your project, for example:
npm i -D prettier-plugin-jinja-template
- It might be tricky to find a well-maintained Nunjucks plugin, but
jinja-templateworks just fine with.njkvia.htmloverride:
{
"plugins": ["prettier-plugin-jinja-template"],
"overrides": [
{
"files": ["*.njk", "*.html"],
"options": {
"parser": "jinja-template"
}
}
]
}
Live example: /anyblades/blades/blob/main/.prettierrc.json
Liquid .liquid #
Official docs:
Syntax highlighting & auto-formatting #
- Simply install
Shopify.theme-check-vscode=/docs/storefronts/themes/tools/shopify-liquid-vscode
That's it! Thanks to Shopify, you do not need to install Prettier separately to format your Liquid code.
The Shopify.theme-check-vscode extension comes bundled with its own instance of the Prettier Liquid plugin, so it works completely out of the box.
Twig .twig NEW #
Docs in progress.