nunjucks | powerful templating engine with inheritance
kandi X-RAY | nunjucks Summary
kandi X-RAY | nunjucks Summary
Nunjucks is a full featured templating engine for javascript. It is heavily inspired by jinja2. View the docs here.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Install native modules .
- Default femter for the element .
- Handle the response
- Search for single selector .
- Animation animation animation
- Creates a new matcher matcher instance .
- Run the webpack configuration
- Creates a new matcher handler .
- invert ajax request
- Create a template error .
nunjucks Key Features
nunjucks Examples and Code Snippets
Community Discussions
Trending Discussions on nunjucks
QUESTION
I'm really excited to see that we can apply a block assignment for set through Nunjucks. What would be the correct way to allow HTML to be passed through this approach?
I want to do the following from my initial nunjucks file:
...ANSWER
Answered 2022-Mar-31 at 15:29Not sure if this is the official way of resolving the situation, but what appears to be working for me now is using |safe as an attribute when the set block is called, like so:
QUESTION
I have this code, that should normally work :
...ANSWER
Answered 2022-Mar-19 at 21:16If you haven't, try updating package.json
with "type": "module"
. Also take a look at the following: Error: require() of ES modules is not supported when importing node-fetch and Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
QUESTION
I set the path appropriately, but there is an error. It comes out well when you proceed with normal html, not nunjucks.
...ANSWER
Answered 2022-Feb-12 at 15:10Put your stylesheet in block
QUESTION
I'm using Eleventy and using Posts. I have set the date in the meta data using the format
date: 2021-09-10
.
I can display the full date using
{{ page.date | readableDate }}
But I want to display just the year (YYYY) within the post content. I'm using Nunjucks.
How do i do this?
I've tried
{{ page.date.getFullYear }}
This gives the following error:
function () { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } return obj[val].apply(obj, args); }
Any help would be really appreciated - thanks!
...ANSWER
Answered 2022-Feb-06 at 14:00Add a filter to your .eleventy.js file
QUESTION
I'm trying to build a site in Eleventy. The site has blog posts in two collections: A and B. When I'm reading a post in the collection A, I'd like to have a link after the post content that says, "View all A posts". And when I'm reading a post in collection B, I'd like to see a "View all B posts" link.
The blog posts share the same _includes template post.html. In that template, I should be able to create an if statement in nunjucks that goes something like this:
...ANSWER
Answered 2021-Sep-27 at 12:59Given that you have blog posts separated by folder, you can create a directory data file that specifies a value for the directory (A, B). Something like so:
QUESTION
I want to call the jQuery function in HTML using Nunjucks, but it's giving me an error. I have imported the JS file into the HTML file.
Error: Unable to call 'fooName', which is undefined or falsey
Does anyone know why I can't call the function? Here is my code example:
...ANSWER
Answered 2022-Jan-08 at 05:51My situation was a bit different but still I think it works in this case too
The idea is to add a function to the global window object
Within the view render method that passes variables to nunjucks I added this function
QUESTION
I have a gulp watch task as following:
...ANSWER
Answered 2021-Oct-29 at 21:44Assuming this is due to rapid file changes, it may help to set the watch delay
option:
gulp.watch(watch.dev, { delay: 500 }, gulp.series("dev"))
If that does not help, you may need to figure out a way to de-bounce the events. There's an old package called gulp-debounce which seems to achieve that, but is unmaintained and so is likely incompatible, but viewing its source may grant some insights.
QUESTION
I'm building a website using Nunjucks and Eleventy. I'm attempting to create an unordered list with a Nunjucks for loop (the data is stored in a JSON file). Everything appears to be working, except that the loop runs twice, when it should only run once.
JSON
...ANSWER
Answered 2021-Oct-06 at 00:00There was a copy of the JSON file saved inside of my input folder. I deleted it and now the HTML output no longer shows the rendered data an extra time. Thank you, @RaymondCamden!
QUESTION
I have a blog built with Eleventy (static site generator), using Nunjucks as the templating language.
I have a page that lists all the tags I've assigned to my posts. It lists them in alphabetical order, with the number of posts per tag.
What I'd also like to do is list the tags in order of frequency (most-used tags first).
The code that works to get the alphabetical list (with counts) looks like this:
...ANSWER
Answered 2021-Sep-16 at 01:47You might be able to use Eleventy custom collections to do what you want. We can use Javascript in the .eleventy.js
file to count the number of posts in each tag, then sort the data by the number of posts.
Since Eleventy doesn't seem to give us a pre-grouped object of tags and posts, we're doing that ourselves. This does mean that if you put duplicate tags on one post, it will be counted twice. It is possible to de-dupe the tags, but it shouldn't be an issue if you're careful.
QUESTION
I need to change this liquid syntax into nunjucks:
...ANSWER
Answered 2021-Sep-04 at 09:18The syntax for passing arguments to Nunjucks filters is a bit different. Try this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nunjucks
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page