Closed ArmorDarks closed 7 years ago
Oh, I see what you're talking about. I need to support async filters. Thanks!
Well, the way we've implemented Nunjucks render
is already right and it's already async-capable, it uses proper callback, required by Nunjucks for async filters.
I think the issues is with Promise itself, since when I was writing it I had very little to no experience with Promises.
Maybe you can point to the original gruntfile? (drop the listing of code or a link, if there's on github) If so, I can take a look.
Hm, it seems to be an error in my filter's promise somewhere.
I've changed it to not use Promise, just to dish out everything in svgo
callback and suddenly it started to work:
# env.addFilter 'Icon', (name, width, height, viewBox, preserveAspectRatio, complete) ->
env.addFilter 'Icon', (name, complete) ->
icon = grunt.file.read "source/icons/#{name}.svg"
svgo = new SVGO()
svgo.optimize icon, (result) ->
complete(null, result.data)
, true
>> 1/1 file compiled.
Besides, my original point was wrong. With code from my first post in place nunjucks-2-html
indeed processed 0/1
templates, no templates actually were rendered. So, I can't figure out why did that happened.
Things happen :)
Let that issue hang around for a while, I will letter do some checks to understand is it's my Promise issue, or nunjucks-2-html
indeed has issues with counting during async calls.
@ArmorDarks hey, hope you're doing well. So, have you taken a look at this once again?
trying to resurrect work here a little bit 😆
Ouch, completely forgot about this one. I think it was an error in my filter, since I wasn't able to reproduce issue.
Sure, no worries, man 👌
Just right now saw that async filters causing issues to calculation of processed pages.
With filter:
(
svgo,optimize
is async and it forcing us to use async filter)grunt nunjucks
will result inHowever, template actually compiled and no errors thrown. I guess, somehow async filter makes count of compiled pages improper.