Adding code comments to DWT



I don't see there being any official way to add comments into the DWT building blocks in tridion, but i've come across a situation where i'd really like to add them without having them appear in the rendered/output html code.

I'm thinking of creating my own syntax for this and writing a tbb to strip them out during publishing.

Has anyone done this, or can suggest another method that works well for commenting?



Posted 2013-07-03T18:35:15.847

Reputation: 12 086



You can use <tcdl:Comment> tags - these get stripped out at request time (I think). See online docs [Login Required]

Will Price

Posted 2013-07-03T18:35:15.847

Reputation: 12 843

wow that's interesting, i'll give this a go – johnwinter – 2013-07-03T18:43:52.893


You can use HTML comments:

<!-- My HTML comment -->

Then write a TBB strip them out; though no need for custom syntax unless you want to differentiate between your DWT logic comments and actual HTML comments that you want to keep.

Nickoli Roussakov

Posted 2013-07-03T18:35:15.847

Reputation: 16 339


When you say creating

your own syntax for this

... do you simply mean pre-fixing/wrapping the HTML comments with some sort of 'strip-me' identifier ... to allow some HTML comments to still push through?

<!-- this comment will make it through -->

<!-- debug:this is an internal comment and will be stripped on LIVE publishing -->

I quite like this as it's simple to use, simple to code out too and the TBB can be adapted to allow different prefixes for different comment requirements)

Dylan .. Mark Saunders

Posted 2013-07-03T18:35:15.847

Reputation: 7 098


Just use an expression with an empty string and a javascript comment

${"" /*This is a comment! */}

Dominic Cronin

Posted 2013-07-03T18:35:15.847

Reputation: 14 997