【发布时间】:2014-07-26 19:03:26
【问题描述】:
目前,我在数组中有一些视图路径,然后是必需的,但我想自动扫描文件夹的目录和子目录:
paths = ['a/', 'b/', 'c/', 'd/d2/', '']
for path in paths
try
View = require(path+name)
catch e
lastError = e
if View
return View
else
throw lastError
我尝试了以下方法,但似乎无法使用 File 类:
paths = []
clientPath = __dirname.replace('/base', '') # go up a directory
currentFiles = []
currentFiles = fs.readdirSync(clientPath)
for file in currentFiles
checkFile = new File(clientPath + "/" + file).isDirectory()
if checkFile
paths.push(file + "/")
在 Backbone 中操作路径字符串的好方法是什么?
【问题讨论】:
标签: javascript backbone.js coffeescript filepath