ColdFusion 8 - 不在 html 源代码中显示注释

发布于 2024-11-25 16:20:05 字数 831 浏览 3 评论 0 原文

当我在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>

如何删除注释,或者如何不显示注释?

When I write a cfc in ColdFusion 8, in the source code ColdFusion shows these comments:

<!-- 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 -->

But I did not write anything, only a function:

<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>

How do I delete the comments, or how do I not show the comments?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冷情 2024-12-02 16:20:05

如果您不想在 HTML 源代码中显示注释,则必须使用 ColdFusion 注释而不是 HTML 注释。

<!--- ColdFusion comments do not show up in source, they are ignored  --->

<!-- HTML comment can be viewed with view source -->

If you don't want to show up comments in your HTML source you have to use ColdFusion comments instead of HTML comments.

<!--- ColdFusion comments do not show up in source, they are ignored  --->

<!-- HTML comment can be viewed with view source -->
晒暮凉 2024-12-02 16:20:05

看起来这些注释已被放入 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.

小霸王臭丫头 2024-12-02 16:20:05

您可以将 output=false 添加到 标记以抑制函数本身的任何输出。如果您只需要返回的查询,这将起作用。

<cffunction name="getMenu" output="false">
  <cfset var getMenu = "">
  <cfquery name="getMenu" dbtype="query" datasource="#request.dsn#">
  select * from Grades ORDER BY gradeID ASC
  </cfquery>

  <cfreturn getMenu />
</cffunction>

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.

<cffunction name="getMenu" output="false">
  <cfset var getMenu = "">
  <cfquery name="getMenu" dbtype="query" datasource="#request.dsn#">
  select * from Grades ORDER BY gradeID ASC
  </cfquery>

  <cfreturn getMenu />
</cffunction>
似最初 2024-12-02 16:20:05

如前所述,鉴于名称,上述注释来自 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文