CFScript 中的 CFDocument(Adobe CF2021)?

CFDocument in CFScript (Adobe CF2021)?

CFSscript 是否特别支持 Adob​​e ColdFusion 2021 中的 CFDocument?

我知道这在以前的版本中是不可能的(但 Lucee 是可能的)。但是,无论哪种方式,我都找不到任何官方文档。我希望有人可以向我指出与此相关的任何文档。

谢谢!

是的,在 ColdFusion 2021 中可以在 cfscript 中使用 cfdocument。

需要说明的是,自 2014 年发布的 CF11 以来,几乎所有标签都作为 cfscript 得到支持。这是 from the intro section in the CFML Reference 的文档:

As general syntax for script support, a ColdFusion tag is invoked like a function call in CFSCRIPT block with tag name is used for the function name. The tag attributes are passed as comma separated name-value pairs to it, like arguments are passed to a function. The child tag (and the body in general) is defined within a curly brackets, just like a function block.

举个例子,这个:

<cfdocument format="pdf">
test
</cfdocument>

可能会变成:

<cfscript>
cfdocument(format="pdf"){
writeoutput("test");
};
</cfscript>

请注意如何您必须在文档正文中使用 writeoutput 来提供 PDF 的内容,即使 cfdocument 不需要任何相应的 cfoutput。 (FWIW,一些 CFML 标签可以,比如 cfsavecontent。)当然你可以使用 cfdocumentitem、cfdocumentsection 等。请参阅文档页面了解如何在脚本中处理嵌套标签。

最后,Adobe 确实从未更改 CFML 参考的每一页以表明 a) 此更改支持所有标签作为脚本,也 b) 显示将每个标签用作脚本。

虽然不幸的是 CFML 参考不是开源的,但为了我们提出更改建议,cfdocs.org 网站是开源的——我只是注意到他们的 page on cfdocument 没有显示使用它作为脚本,所以我会尝试提供 PR。