Skip to content

How to add custom Nunjucks Filters #5

@andriusdj

Description

@andriusdj

Hello,

Sorry in advanced for my noobishness in this...

I have made a custom Nunjucks Filter but I can't find a way to add it to the Unibit dependency Nunjucks in order to extend it as it was described in Nunjucks documentation..

Could somebody help me to navigate through this?

The custom filter I made is in the file located at /index.js has the following:

var nunjucks = require('nunjucks');
var env = new nunjucks.Environment();
var crypto = require('crypto');

env.addFilter('md5', function(str) {
    return crypto.createHash('md5').update(str).digest("hex");
});

But it is not being picked up by anything..

What i need is the following to work:

{% hash = some_variable | md5 %}

Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions