Skip to main content
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Hi, my name's David - I'm new here :-)
I've installed Silverstripe and I'm so impressed that I'm using it for two sites I'm doing at the moment. I'm playing around with templates and want to know if it's possible to comment out code.
I can use HTML's <!-- --> but the template code still gets processed.
I'm looking at the BrightSide1 template which spews out errors if you don't have a page called 'Blog'. I want to comment out that code, in the .ss file so I can refer to it later. Is this possible?
My apologies if there's some reference somewhere that explains this - I searched through the docs and the forums and couldn't find anything.
Thanks in advance,
Welcome to Silverstripe ! Good choice ! ;-)
That is a good question .. I remember there was talk about this some time ago...
Kinda' forgot wat the outcome was..but AFAIK it has not been implemented yet. ;)
Thanks fuzz, I appreciate it!
I've had a cursory look at parseTemplateContent() in sapphire/core/SSViewer.php , and I can see where it's processing the <!-- --> - I don't think it'd be too hard to modify my own version so that the stuff inside html comments doesn't get processed.
I know comments are nothing huge and I could just make a backup of the template file, but I find it helpful to comment out code when I'm learning something new, it helps me pinpoint where my bugs are.
thanks again :-)
It's documented here: http://doc.silverstripe.org/sapphire/en/reference/advanced-templates#comments
Comments in .ss files like this...
<%-- this is a comment --%>
...must have the start & end tags on the same line, so this will not work...
<p>comment this out temporaily for debugging purposes</p>
<div>and this too etc...</div>
...which is a pity. It would be useful.