白色空间/冷融合 [英] White Space / Coldfusion
问题描述
停止 ColdFusion 输出的空白的正确方法是什么?
What would be the correct way to stop the white space that ColdFusion outputs?
我知道有 cfcontent
和 cfsetting enableCFoutputOnly
.这样做的正确方法是什么?
I know there is cfcontent
and cfsetting enableCFoutputOnly
. What is the correct way to do that?
推荐答案
除了
,
In addition to <cfsilent>
, <cfsetting enablecfoutputonly="yes">
and <cfprocessingdirective suppressWhiteSpace = "true">
is <cfcontent reset="true" />
. You can delete whitespaces at the beginning of your document with it.
HTML5 文档会像这样开始:
HTML5 document would then start like this:
<cfcontent type="text/html; charset=utf-8" reset="true" /><!doctype html>
XML 文档:
<cfcontent reset="yes" type="text/xml; charset=utf-8" /><CFOUTPUT>#VariableHoldingXmlDocAsString#</CFOUTPUT>
这样您就不会收到 XML 文档的Prolog 中不允许内容"错误.
This way you won't get the "Content is not allowed in prolog"-error for XML docs.
如果您从函数中得到不需要的空格,请使用 output
-属性来抑制任何输出并将结果作为字符串返回 - 例如:
If you are getting unwanted whitespaces from a function use the output
-attribute to suppress any output and return your result as string - for example:
<cffunction name="getMyName" access="public" returntype="string" output="no">
<cfreturn "Seybsen" />
</cffunction>
这篇关于白色空间/冷融合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!