SilverStripe Quick Tip: Comments in TemplatesSilverStripe Quick Tip: Comments in Templates

Posted May 11th, 2010 in Quick Tips and SilverStripe

It's funny how we programmers don't tend to read documentation (well I often don't tend to anyway - at least not cover to cover) and turn to search engines to find the answers to our questions. When looking for something quite different from what this post is about I stumbled across the SilverStripe templates documentation page and discovered how to put comments into a SilverStripe template that will be stripped out of the published site. So here's a quick tip to point it out to those of you who use SilverStripe and may not already know this.

Adding comments to a SilverStripe template

I was doing an awfully hacky thing ( doing this: <% if false %> comments here <% end_if %> ) and discovered the right way to add a comment that will be stripped out of the published site, using <%-- and --%> like so:

<%-- put your comments here --%>

You can also use regular <!-- --> HTML style comments but of course these will be sent to the browser whereas the SilverStripe style comments will not.

Related posts:

Comments

blog comments powered by Disqus