Tags:
create new tag
view all tags

Question

Is there any way to comment out text so that it does not appear in the HTML source for the page? I realize I can use HTML comments (<!-- ... -->), as mentioned in AddingCommentInTemplate. But sometimes I don't want the commented out text to appear in the generated HTML. Maybe it's long, or internal documentation, or a to do list for the page, etc. Seems to me there should be a TWiki-level comment syntax in addition to HTML comments. Is there some TWiki markup I could abuse for this? Perhaps something that generates no HTML because it is malformed or incomplete or whatever?

  • TWiki version:
  • Web server:
  • Server OS:
  • Web browser:
  • Client OS:

-- MitchellModel - 03 Nov 2002

Answer

There is no existing command for that. You could write a Plugin or simply add a new rule to the commonTagsHandler subroutine of DefaultPlugin. Here is an example that hides everything between <hide> ... </hide>

    $_[0] =~ s/<hide>.*?</hide>//gos;

-- PeterThoeny - 04 Nov 2002

I didn't know that rules could be added to DefaultPlugin like that -- very cool! Thanks.

-- MitchellModel - 06 Nov 2002

BTW there is no need for the 'o' option on the right hand side of s/// unless the left hand side includes a variable smile ... There is a topic about this in the context of ModPerl.

-- RichardDonkin - 08 Nov 2002

Also, of course, you can't use slash as the delimiter without backslashing the slash in </hide>, but I wasn't looking for working code, just a way to do it. smile I think it would be worth documenting how to add your own formatting tags to TWiki, since it's this simple. (I know that might open up the proverbial worm can, but used judiciously it seems a very powerful way to customize a site for special purposes.) Or maybe it is documented somewhere but I either didn't see it or didn't realize I could do that to solve my problem.

-- MitchellModel - 08 Nov 2002

Yep, untested code embarrassment

    $_[0] =~ s/<hide>.*?<\/hide>//gs;

This is untested again, but should work big grin

-- PeterThoeny - 08 Nov 2002

What effect, if any, would such changes have on the parsing of the text for TWiki functionality, for example, in the setting of variables ??

Is it safe to assume that DefaultPlugin only gets hold of the data as the last thing before it's sent to the browser ?

-- MichaelKearns - 02 Jan 2003

No, it's not. It would if you stuck the above in endRenderingHandler...the only things that come after that are (maybe) other plugins' endRenderingHandlers, the restoration of <verbatim> text (which is stored away safely before rendering), and a few other inconsequential things. On the other hand, commonTagsHandler gets just before rendering begins. Nonetheless, I haven't looked enough in the TWiki code to find where it pulls out variable settings, but something tells me that it does so even before it begins to render, so if that's all you're concerned about then things will still work.

-- WalterMundt - 23 Jan 2003

Why not instead use the ConditionalPlugin? With it, you would have more flexibility when the block should or should not render. For this plugin, you could, for instance, hide the block unless the user were part of a specific group (such as the admin group).

-- TomKagan - 24 Jan 2003

Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2003-04-30 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.