在CouchDB中使用require()或//!json,!code? [英] Using require() or // !json, !code in CouchDB?

查看:62
本文介绍了在CouchDB中使用require()或//!json,!code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CouchDB权威指南中,作者说您可以使用:

In the CouchDB Definitive Guide the author says you could use:

// !json templates.edit
// !json blog
// !code vendor/couchapp/path.js
// !code vendor/couchapp/template.js

但是为什么要使用那些宏,何时可以使用require()?

But why use those macros when you can use require()?

有时候我想使用宏吗?

推荐答案

基本上,只有在将CouchDB与 CouchApp 一起使用时,才有意义。

Basically this is only of interest when using CouchDB with CouchApp.

它可以更轻松地将数据与show函数分离。

通常,CouchDB使用Mozilla的SpiderMonkey JavaScript Engine渲染视图,因此

It allows for easier separation of the data from the show function.
Normally CouchDB uses the Mozilla's SpiderMonkey JavaScript Engine to render the views, therefore there is not CommonJS implementation available.

基本上CouchApp允许您使用JavaScript的显示功能(存储在数据库中)来渲染H。 TML。

Basically CouchApp allows you to use those JavaScript "show" function (which are stored in the DB) for rendering out HTML.

因此,就Node.js而言,使用宏确实没有任何意义。另外,我迅速浏览了Node.js可用的两个CouchDB模块的源代码,但找不到对宏的任何支持,这进一步表明这是某些CouchApp特定的功能。

So in terms of Node.js, no it doesn't really make sense to use the macros. Also, I quickly looked through the soruce of two of the available CouchDB modules for Node.js, and I couldn't find any support for the macros, which further indicates that this is some CouchApp specific functionality.

这篇关于在CouchDB中使用require()或//!json,!code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆