gpt4 book ai didi

couchdb - 您应该将模板存储在 couchapp 的什么位置?

转载 作者:行者123 更新时间:2023-12-01 13:00:44 26 4
gpt4 key购买 nike

在 couchDB 指南中,Managing Design Documents , 他们说

The _attachments directory contains files that are saved to the Sofa design document as binary attachments. CouchDB serves attachments directly (instead of including them in a JSON wrapper), so this is where we store JavaScript, CSS, and HTML files that the browser will access directly.

然后他们在 _attachments 文件夹之外创建了一个单独的文件夹来存储他们的模板。这是让我困惑了一段时间的事情。我能够在我的展示功能中包含模板的唯一方法是它们位于 _attachments 文件夹之外。

我可以将我的模板放在 _attachments 文件夹中,还是应该放在 _attachments 文件夹之外?

如果我可以/应该将它们放在 _attachments 文件夹中,我该如何在我的显示函数中调用它们?

最佳答案

如果您想在服务器端呈现模板(_show_list 函数),它们一定不能在_attachments 中,因为 show 和 list函数无权访问附件。在这些函数中,变量 this 是一个 Javascript 对象,从设计文档中复制而来。 this.templates.foo 将来自项目中的 templates/foo.html 文件。

如果您想在客户端(浏览器)端呈现模板,它们可能在附件中,在设计文档中。这取决于什么对你更有效。模板保存在附件中,可以直接获取模板,在客户端使用;您只需在您的应用程序或网页中链接到它。您还可以将模板留在设计文档中,让客户端获取整个文档。然后,客户端可以使用它想要的 ddoc 中的任何模板。

关于couchdb - 您应该将模板存储在 couchapp 的什么位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6119559/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com