I really needed to add some comments to my template code today and couldn’t find a way to do this yet so I ‘wrote’ a plugin. You can use this plugin to hide code snippets or to add textual comments to your templates. Please let me know if something like this already exists or if you guys (Rick, Paul) will be adding something similar to EE soon.
If anyone finds it useful I might submit it, but for now you can download it here.
I just uploaded a new version and downgraded it to 0.2 because it needs some more work. Added a ‘style’ parameter to specify what comment style you want to use.
{exp:hide} This is the default style (none) which will just hide the entire code or text and nothing will show up in the source of your browser
{exp:hide style="html"} <!– for HTML style comments –>
{exp:hide style="css"} /* CSS comments */ (using the values “php” or “js” will return the same style for PHP or JavaScript comments)
There are still some things to work out, one of them is nesting. For example, this won’t work:
{exp:hide style="html"}
{exp:hide}
code or text you want processed
{/exp:hide}
{/exp:hide}
I will be away untill after the weekend, enjoy!
Cool idea.
I’ve been doing a lot of plugin stuff myself recently and I’m pretty sure you are correct about the parsing. Plugins seem to be the last thing to go through the engine. So if an EE tag is in there it will get parsed and then the plugin will hide it afterwards so you can’t use your plugin for a performance gain of any kind.
But I like the idea of having comments hidden from users while still being able to view them in your templates. It would also be interesting to add the ability to have it not hide them in the source when a person logged in as a certain member group is viewing the page. So admins could still open the source and see comments but normal users would not.
Jamie
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.