我有一个保存表格的 cfsavecontent 标记。后来我使用 cffile 将保存的内容写入文件。当我查看那个文件时,我看到<td>
表格中的标签后面插入了许多空行;</tr>
并在标签后插入几行空行。(尽管它不会在代码<tr><td> </td></tr>
在一行中全部显示的情况下做到这一点。)
目前我有一个包含其中两个表的文件。这些表在循环中生成,并使用 cffile append 创建输出文件。这个文件有 915 行,其中可能有 30 行是非空白的。我所有的后续代码都可以正常工作,但这只是测试数据。在现实世界中,我可能有 1000 个或更多表,而且我担心文件大小。
编码:
<cfset head1 = 'from = "moxware" '>
<cfset head2 = 'to = "#hrep.PersonEmail#" '>
<cfset head3 = 'replyto = "#replyto#" '>
<cfset head4 = 'subject = "#subject#" '>
<cfset head5 = 'type = "html" '>
<cfsavecontent variable = "abc">
<cfoutput>
#head1#
#head2#
#head3#
#head4#
#head5# >
#xyz#
</cfoutput>
</cfsavecontent>
<cffile action = "append"
file = "/var/www/reports/moxrep/#reportout#.cfm"
output = "<cfmail"
mode = "777" >
<cffile action = "append"
file = "/var/www/reports/moxrep/#reportout#.cfm"
output = "#abc#"
mode = "777">
<cffile action = "append"
file = "/var/www/reports/moxrep/#reportout#.cfm"
output = "</cfmail>"
mode = "777" >
关于 xyz,我正在从文件中读取它:
<cffile action = "read"
file = "/var/www/reports/moxrep/#reportname#.cfm"
variable = "xyz">
文件如下所示:
<link rel="stylesheet" href="sample.css">
<link rel="stylesheet" type = "text/css" href ="betty.css"/>
<p style="margin-left:40px"><span style="font-size:14px"><span style="font- family:georgia,serif">Dear Customer,</span></span></p>
We were so pleased that you have signed up for one of our programs. Apparently you live in the city of {{1. Additionally we observe that your were referred to us by {{2. Below please find a listing of what you signed up for.</span></span></p>
<p style="margin-left:40px"><span style="font-size:14px"><span style="font- family:georgia,serif">{{r</span></span></p>
<p style="margin-left:40px"><span style="font-size:14px"><span style="font-family:georgia,serif">Sincerely Yours,</span></span></p>
<p style="margin-left:40px"><span style="font-size:14px"><span style="font-family:georgia,serif">John Jones<br />
President<br />
XYZ Corporation</span></span></p>
该文件是由代码生成器创建的,而不是我,所以有点麻烦。稍后在代码中,我替换了以 {{ ; 开头的所有内容 特别是 {{r 被替换为表格,这就是额外空间的来源。
追加本身没有插入任何额外的行。
有谁知道是什么导致文件中这些额外的空白行?以及如何摆脱它们?