Skip to content

How to list files in folder from a ejs file #5226

Discussion options

You must be logged in to vote

Currently, all ejs files are executed in their own VM and context, and ejs can not have access to any Node.js built-in globals at all.

You can, however, create a custom hexo helper plugin to inject variables. Here is an example:

https://github.com/SukkaW/hexo-theme-suka/blob/1d457ac9fbad421d2e6b9853ae1cb3dfc5cadf05/scripts/index.js#L17
https://github.com/SukkaW/hexo-theme-suka/blob/master/includes/helpers/qrcode.js
https://github.com/SukkaW/hexo-theme-suka/blob/1d457ac9fbad421d2e6b9853ae1cb3dfc5cadf05/layout/_partial/menu/index-share.ejs#L57

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by uiolee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants