0

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?

Leigh
  • 28,765
  • 10
  • 55
  • 103
  • 1
    I think you'll have to give us much more detail here. I don't see any comments in the code you posted, just a query and a return statement. I would like to give you a few pointers though, make sure that getMenu is var scoped in the beginning of the function, and I'd also set the columns you are trying to select instead of * in your select statement. – bittersweetryan Jul 22 '11 at 15:41

4 Answers4

8

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 -->
Andreas Schuldhaus
  • 2,618
  • 2
  • 19
  • 22
2

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.

John Whish
  • 3,016
  • 17
  • 21
0

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.

Michael Long
  • 1,046
  • 8
  • 15
0

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>
Yisroel
  • 8,164
  • 4
  • 26
  • 26