Alexander Alvarez
Alexander Alvarez

Reputation: 21

ColdFusion 8 - Not show comments in html source

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?

Upvotes: 0

Views: 1146

Answers (4)

Michael Long
Michael Long

Reputation: 1102

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.

Upvotes: 0

John Whish
John Whish

Reputation: 3036

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.

Upvotes: 2

Andreas Schuldhaus
Andreas Schuldhaus

Reputation: 2648

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

Upvotes: 8

Yisroel
Yisroel

Reputation: 8174

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>

Upvotes: 0

Related Questions