CGI::Toggle(3pm)

πŸ“¦
version 2.56 Β· 5 versions
, in ubuntu questing

πŸ’– CGI::Toggle πŸ’–

okay bestie, welcome to the manual page for CGI::Toggle β€” that's the CGI::Toggle(3pm) page from the User Contributed Perl Documentation, the one and only ✨ utility methods for collapsible sections ✨. yes, collapsible sections. the little clicky open/close thingies. it's giving accordion but make it Perl. πŸͺ—


🌸 NAME 🌸

CGI::Toggle β€” utility methods for collapsible sections πŸŽ€


✨ SYNOPSIS ✨

use CGI ':standard'; use CGI::Toggle

print header(),
  start_html('Toggle Test'),
  h1("Toggle Test"),
  toggle_section({on=>1},p('This section is on by default'),
  toggle_section({on=>0},p('This section is off by default'),
  toggle_section({plus_img=>'/icons/open.png',
                  minus_img=>'/icons/close.png'},
                 p('This section has custom open and close icons.')),
  hr,
  end_html;

look at that. three whole sections. one open, one closed, one with custom icons. a whole mood. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so this package adds JavaScript-based support for collapsible sections, and it does it by adding exactly one single new function: toggle_section(). one function. that's it. iconic behavior honestly.

⚠️ important, no cap: it overrides the CGI start_html() method, so you must import CGI before you bring this module in. order matters bestie, do not play with this one. 😭

🧚 METHODS 🧚

($control,$content) = toggle_section([\%options],$section_title=>@section_content)

okay so this method takes:

  1. an optional \%options hashref,
  2. a section title,
  3. and one or more strings holding the section content.

and what does it give back? a list of HTML fragments β€” one for the control link and one for the content. 🫢

and if you call it in scalar context? the control and the content get concatenated together into one thing. slay.

the option keys are as follows, bestie, take notes πŸ“:

  • on β€” if it's true, the section starts out on (visible) by default. the default is false, meaning collapsed. so if you say nothing, it's closed. shy little section. πŸ™ˆ
  • plus_img β€” the URL of the icon that shows up next to the section title when the section is collapsed. the default is /gbrowse2/images/plus.png. πŸ“
  • minus_img β€” the URL of the icon that shows up next to the section title when the section is expanded. the default is /gbrowse2/images/minus.png. πŸ“‚
  • override β€” if it's false (which is the default), the state of the section gets remembered in a session variable. if it's true, the initial state comes straight from the on option and the session gets ignored. periodt. πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

CGI

that's it. that's the whole list. it's a one-module fandom. πŸ’œ


🌈 AUTHOR 🌈

Lincoln Stein <lstein@cshl.org>. πŸ’–

Copyright (c) 2005 Cold Spring Harbor Laboratory

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.


okay and for the cute sign-off: this page is from perl v5.40.0, dated 2024-10-20, and it lives under the name CGI::Toggle(3pm) β€” so now you know exactly which version and which day you're reading. go forth and collapse things, bestie. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from