Closed 1v9 closed 5 years ago
Benchmark (Need more test cases) https://github.com/stevenjoezhang/nunjucks-vs-swig
GitHubContribute to stevenjoezhang/nunjucks-vs-swig development by creating an account on GitHub.
MediumIn JavaScript land the pace of development moves very fast and there are literally hundreds of competing libraries to accomplish almost…
Ah, although I use neither Hexo nor NexT now, I can still help about things of nunjucks plugin, though I have not upload my plugin a lot time, I think it's still the newest alive nunjucks plugin.
By the way, it's name on https://npmjs.com is called hexo-renderer-njucks
because hexo-renderer-nunjucks
hexo-renderer-njks
hexo-renderer-njk
are all dead.
About Unable to call Date["now"], which is undefined or falsey
:
Nunjucks does not work like ejs or swig, which treat expressions as JavaScript expressions, you need to register JavaScript function them and then you can use them, so try to passing them via Hexo, I am not familiar to how to do this with Hexo, but it should work.
@stevenjoezhang @ivan-nginx @1v9 About https://github.com/theme-next/hexo-theme-next/pull/1068#issuecomment-518756742, although I never use import
, I find something related to this problem (from https://mozilla.github.io/nunjucks/templating.html#set):
It is also possible to capture the contents of a block into a variable using block assignments. The syntax is similar to the standard set, except that the = is omitted, and everything until the {% endset %} is captured.
So nunjucks says endfor
is unknown may because you set current_year
without a initial value, and nunjucks treats it as a block assign, you may change https://github.com/theme-next/hexo-theme-next/blob/290fc6c497b843b36dada50500720b5f825a15d2/layout/_macro/post-collapse.swig#L4 (and other places like this) into:
{% set current_year = '1970' %}
and test again, I don't have a valid _config.yml
for NexT, so I cannot test it now.
@AlynxZhou Thanks so much!
@AlynxZhou Thanks so much!
Nothing, if you never find my repo and reference my issue, I would never see this.
Looks like layout_macro\post.swig) [Line 223, Column 61] - expected block end in include statement
and layout\archive.swig [Line 29, Column 11] - Unhandled rejection Template render error: unknown block tag: endif
are also the same reason, so go for a test and see whether is has been solved.
Thanks, I'll check for that.
Moreover, your theme - hexo-theme-aria, is pretty nice. I have already referenced some code from it, otherwise I might waste a whole day figuring out why page.posts
in for tag doesn't work with out toArray()
😂
Jobs done
Any developer could log issues here, see njk, should use Hexo v4/master version.
Hexo:
TypeError: Cannot read property 'replace' of null at Hexo.externalLinkFilter
[ ]
TypeError: Cannot read property 'match' of null at Hexo.hexoMetaGeneratorInject
NexT plugin:
[x]
Error: filter not found: json_encode
(usedump
in hexo-next-title)On the road:
null
except archive page, no errors again.Unhandled rejection Template render error: unknown block tag: endif
Unhandled rejection Template render error: unknown block tag: endfor
https://github.com/theme-next/hexo-theme-next/pull/1068#issuecomment-518756742Pending:
TypeError: Cannot read property 'charAt' of undefined
TypeError: Cannot read property 'charAt' of undefined
Unable to call
__, which is undefined or falsey
expected block end in include statement
Unable to call
__, which is undefined or falsey
Unable to call
Date["now"], which is undefined or falsey
template not found: localsearch.swig