节点模块中的每个请求变量? (表达视图助手)
我正在开发这个项目 https://github.com/tanema/express-helpers 我分叉修复并添加新功能。
我想要做什么,而不是必须使用 form_tag_end() 甚至 end_tag('tagname') 我只想使用 end() 方法。为此,我需要某种堆栈实现,以便在发出开始标记时将其推送到堆栈等。我不能只在名为 tagStack 的模块中创建一个变量并使用它,因为它会创建一个竞争条件,其中该模块被两个请求同时使用,并且堆栈顺序会变得混乱。
我在想,如果有某种方法可以访问请求变量,我只需将其存储在其中并删除该变量(如果为空),但我不知道如何做到这一点。
有什么建议吗?
I am working on this project https://github.com/tanema/express-helpers that I forked fixed up and added new functionality to.
What I want to do it, instead of having to use form_tag_end() or even end_tag('tagname') I would just like to use a end() method. For this to work I need some sort of stack implementation for when a start tag is issued push onto the stack ect. I cannot just make a variable in the module called tagStack and just use that because it would create a race condition where the module is being used at the same time by two requests and the stack order gets messed up.
I was thinking if there was some way to have access to the request variable I would just store it in that and delete the variable if empty but I can't figure out how to do that.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在闭包中创建变量;它将在实例的范围内可用,但在函数的实例化之外不可用,并且当特定实例超出范围时将被垃圾收集。
Create your variable within a closure; it will be available within the scope of the instance, but not outside the instantiation of the functions, and will be garbage collected when the specific instances go out of scope.