Closed array-in-a-matrix closed 9 months ago
The expected output should be like the following code:
import os for i in walkDir("."): echo i # outputs current directory's contents
Well, that code doesn't work when placed outside the route either, in global scope. It only works if you put it in a static:
block, in which case it is run as nimscript during the compilation process. The issue with most of the path procs from std/os is that they are not supported in browser js scripts, since the browser sandboxes code and hides access to the directory structure on the front end.
Since a SPA project is on the front-end, you either want to show the directory structure in which the project exists, which can only be gotten at compiletime, or you want your SPA script to be able to search around independently on a visitor's directory structure, which is a huge security no-no that browser sandboxing is meant to avoid. Or, you don't want to use a SPA at all and instead want to use an SSR to dynamically explore your own file structure.
Oh right, everything is being loaded client side so the file directory isn't available. Thank you for your explanation! I will probably switch to SSR or SSG then.
Describe the bug π A clear and concise description of what the bug is.
The
walkDir
iterator outputs nothing regardless of the contents of the directory.To Reproduce π¨βπ¬ Steps to reproduce the behavior:
appRoutes("app"): "/": tDiv: for i in walkDir("."): # does not work on all paths {i} # only an empty div is created regardless of how many files/directories exist
Expected behavior π€ A clear and concise description of what you expected to happen.
The expected output should be like the following code:
Using this code on https://play.nim-lang.org, outputs the following:
Please complete the following information π
hpx -v
) HappyX 3.8.0Additional context β Add any other context about the problem here.
This may affect other iterators like
walkDirs
andwalkDirRec
. I did not check that though.