You need to log in before you can comment on or make changes to this bug.
This bug replicates bug 2238 from the deprecated Chameleon bugzilla. This is not a major problem or anything but I find that during template create one goes through alot of widget placement and testing. Currently, you have to rip out the entire cwc2 tag if you don't want it to render on the page. Would it be possible to reserve a comment for it so that you can leave it in the template and the parser will just ignore it? Or better yet ... if it encounters a widget commented out then it replaces the whole widget with   or something. I would think a commnet like:: <!cwc2 type="...."/> parsed as would be nice. Just a thought Jay
this is possible. I would prefer to use something like <!--<cwc2 .... />--> though. In this case, we can use the existing template parser with a second regex for detecting this case and emitting the whole commented tag back into the output. It may even allow for whitespace between the <!-- and the <cwc2.
Not to invalidate what Paul suggested, but I would be confused if <!--<cwc2..></cwc2>--> successfully commented out the tag, but <!-- <td>etc</td> <td>more tags</td> <td><cwc2...></cwc2></td>--> didn't. Make sense?
I don't know in depth details about the actual cwc2 tag parser, however, if the parser inherits a generic XML parser, then shouldn't this be a non-issue? If not, why are we using a hand-made parser to parse the cwc2 tags?
> If not, why are we using a hand-made parser to parse the cwc2 tags? Because we don't need a real parser. The current method is not a parser: it only looks for the CWC2 tags using regular expressions and only does textual replacements... it's as optimal as it gets while remaining very flexible and easy to maintain. A real parser would add tons of unnecessary overhead and probably wouldn't work on HTML documents anyway: most of the time HTML doesn't validate as XML (I know it could in theory, but people are lazy), and just an unclosed XML tag (such as <p> or <br> which are extremely common) is enough to confuse any XML parser.
we are not for (at least) these reasons: 1. HTML is not valid XML 2. speed. it it not necessary to parse the rest of the contents of the page, just the cwc2 tags 3. replacement. The parser not only identifies tags, but also replaces them with the widget output as well, this would involve more steps using a regular XML parser. we may be able to set up the regex to ignore cwc2 tags that appear inside <!-- --> comment tags. Or we may not ... to be determined.
opps, didn't see Daniel's comments :) At least we are consistent.
That's a good sign! :)
any solution is going to make chameleon slower. Should we actually support this? If yes, then I propose to run two parser passes on the template, one to extract comments and a second to extract widgets. This would remove commented out widgets from the template, but would require two passes. Not sure what the performance implications of this would be. Note to implementor: build regex to extract <!-- up to -->, create new instance of TemplateParser with this regex, process template, insert empty string ("") as replacement for all comments, run replacements, and then pass resulting page to the regular parser.
If we are going for a standarized approach to commenting then <!-- --> would be the path to take as we are dealing with HTML as well. Note that simply removing cwc2 from the tag itself seems to do the trick with no (noticeable) implications. Is this sufficient as a solution? The end result is not valid HTML - this is a definite drawback, however, the use of a commented widget in production *should* be rare. The original intent of this post was to assist with application development (so that the parser would not choke).
My 0.02$ on this: If you do this then go with <!cwc2...> as was initially suggested since this makes it very quick to comment a tag and will have the least performance impact. The <!cwc2> tags would simply be replaced with an empty string using preg_replace. Processing all HTML comments would have a bigger impact on performance, plus you would lose all the legitimate HTML comments unless you support some king of nested parsing as suggested above (complexity == bugs). Also, the day there is a user-friendly template editor for Chameleon, it will be much easier for that editor to catch <!cwc2...> than <!-- ... blah <cwc2...> ... -->. Finally, the docs should state clearly (in bold-italic-red-underlined) that commented widgets should be taken out of a template on production servers for performance reasons.
updated version to 1.99
I like daniel's suggestion the best. <!cwc makes total sense to me, and I also like the suggestion of it returning nothing as opposed to a space or an btw, I think this will be great for debugging templates!
Changed target to 1.99 RC1.
Changed Severity to normal.
This can be accomplished by setting enabled="FALSE" in the widget. This will result in the widget being completely deactivated and removed from the interface, but will leave the tag in the page as an HTML comment <!-- <cwc2 ....></cwc2> -->