ColdFusion 8 - 不在 html 源代码中显示注释
当我在ColdFusion 8中编写cfc时,在ColdFusion源代码中显示了这些注释:
<!-- application.cfm BEGIN -->
..
<!-- app_include.cfm BEGIN -->
..
<!-- app_include.cfm END --> <!-- BEGIN variableDeclarations.cfm -->
...
<!-- END variableDeclarations.cfm OR #request.directory# contains "storeworks"-->
...
<!-- application.cfm END -->
但我什么也没写,只写了一个函数:
<cfcomponent Hint = "Test" displayname="Test" output="true">
<cffunction name="GetProducts" returnformat="json" output="false" access="remote">
<cfquery name="getMenu" dbtype="query" datasource="#request.dsn#">
select * from Grades ORDER BY gradeID ASC
</cfquery>
<cfreturn getMenu />
</cffunction>
</cfcomponent>
如何删除注释,或者如何不显示注释?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您不想在 HTML 源代码中显示注释,则必须使用 ColdFusion 注释而不是 HTML 注释。
If you don't want to show up comments in your HTML source you have to use ColdFusion comments instead of HTML comments.
看起来这些注释已被放入 Application.cfm 文件中,该文件在每个请求上运行。
正如 Andreas 已经说过的,如果您将这些注释更改为使用 3 个破折号而不是 2 个破折号,那么它们将不会出现在 HTML 源代码中。
It looks like those comments have been put into the Application.cfm file which runs on every request.
As Andreas has already said, if you change those comments to use 3 dashes instead of 2 dashes then they won't appear in the HTML source code.
您可以将 标记以抑制函数本身的任何输出。如果您只需要返回的查询,这将起作用。
output=false
添加到You can add
output=false
to the<cffunction
tag to suppress any output from the function itself. This will work if all you need is the returned query.如前所述,鉴于名称,上述注释来自 cfapplication 文件。虽然将注释更改为 cf 注释会有所帮助,但更好的解决方案是将以下 cfsetting 标记添加到 cfapplication 文件的最顶部和底部。
这将抑制所有注释、任何无关字符,最重要的是,抑制 application.cfm 文件中可能生成的任何无关空格。
您是否注意到在生成的 HTML 中,您的 DOCTYPE 行被数十个 CR 推到了页面下方?此帮助将修复它。
As mentioned, given the names, the above comments are coming from the cfapplication file. While changing the comments to cf comments will help, a better solution is to add the following cfsetting tags to the very top and bottom of your cfapplication file.
<cfsetting enablecfoutputonly="yes">
<!-- your application.cfm code -->
<cfsetting enablecfoutputonly="no">
This will suppress all comments, any extraneous characters, and above all, any extraneous whitespace that may be generated in your application.cfm file.
Ever noticed in your generated HTML that your DOCTYPE line is being pushed down the page by dozens of CRs? This help will fix it.