Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Error Messages are not displayed when they are only strings when using nunjucks rendering engine #103

Open
tylkomat opened this issue Apr 24, 2015 · 1 comment

Comments

@tylkomat
Copy link

In flash-messages.html the test {% if message %} is always true, either if message is a string or an object, so always the "object" route is taken.

I extended the test to {% if message.title or message.detail or message.list %} which solves this problem, but there should be a better solution.

@tylkomat tylkomat changed the title Error Messages are not displayed when they are only strings wihen using nunjucks rendering engine Error Messages are not displayed when they are only strings when using nunjucks rendering engine Apr 24, 2015
@tylkomat
Copy link
Author

One Option would be to create a custom filter.

In keystone.js add:

var cons = require('consolidate'),
      nunjucks = require('nunjucks');

cons.requires.nunjucks.addFilter('is_object', function(obj) {
    return typeof obj == 'object';
});

and then in templates/mixins/flash-messages.html {% if message %} has to be changed to {% if message | is_object %}.

I can create a pull request if necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant