Just in case you find it usful, I'm offering some code I wrote recently, to interface with Bootstrap. It includes methods to generate panels, buttons, dropdowns, and alerts.

I don't consider this useful/tested enough to deliver to CPAN, but it works for my uses.

#--------------------------------------------------------------------- +---------------------- # B O O T S T R A P H E L P E R M O D U L E ("Twitter Bootst +rap" JS) #--------------------------------------------------------------------- +---------------------- package BootstrapHelper; # Helps create Bootstrap EventDetailHandler_E +numerate_Instances use CGI; #------------------------------- sub new{ my ($class, %atts) = @_; return bless ({ %atts } ,$class); } #------------------------------- sub panel{ # $bs->panel (heading=>"my title",content=>"important stuff +",class=>"panel-danger"); my ($self,%atts) = @_; $atts{class} ||= "panel-info"; $atts{heading} ||= "Info"; return CGI::div({-class => "panel $atts{class}"}, join "\n", CGI::div({-class=>"panel-heading"}, CGI::h3({-class=>"panel-title"},$atts{heading}) ), CGI::div({-class=>"panel-body"}, $atts{content}) ) . "\n"; } sub alert{ my ($self,%atts) = @_; $atts{class} ||= "alert-info"; $atts{dismiss} and $atts{class} .= " alert-dismissable"; $atts{heading} ||= ""; # Text to be highlighted return CGI::div({-class => "alert $atts{class}"}, join "\n", ($atts{dismiss} ? $self->button(dismiss=>1, class=>"clos +e") : ""), ($atts{heading} ? CGI::strong($atts{heading}) . " " : "" +), $atts{content} ) . "\n"; } sub button{ # Cannot use CGI::button, since that one produces an <inpu +t> tag my ($self,%atts) = @_; $atts{class} ||= "btn-info"; $atts{content} ||=""; $atts{dismiss} and $atts{content} .= "&times"; return qq|<button type="button" class="btn $atts{class}" | . ($atts{dismiss} ? qq|data-dismiss="alert" aria-hidden="true" | +:"") . ($atts{onclick} ? qq|onclick="$atts{onclick}" | :"") . ">" . $atts{content} . qq|</button>\n|; } sub dropdown{ my ($self,%atts) = @_; $self->{DROPDOWN_COUNT}++; $self->{DROPDOWN_ID} = "dropdown_menu_$self->{DROPDOWN_COUNT}"; # Mo +st recent ID is here $atts{class} ||= "btn-info"; $atts{content} ||= $atts{selected_value} || "Button-name"; # Gets ov +erriden by default anyway $atts{values} ||= []; $atts{selected_value} ||= "***NONE***"; $atts{input} ||= ""; # Allow for optional <input> text tag (Whose ID + should be set to THIS control's data-target) my $target_txt = $atts{'data-target'} ? "data-target=\"$atts{'data-t +arget'}\" " : ""; return <<" __DROPDOWN__" <div class="dropdown"> <button class="btn $atts{class} dropdown-toggle" type="button" data +-toggle="dropdown" aria-haspopup="true" id="$self->{DROPDOWN_ID}" $target_txt aria-expanded="true"> $atts{content} <span class="caret"></span> </button> $atts{input} <ul class="dropdown-menu" aria-labelledby="$self->{DROPDOWN_ID}"> __DROPDOWN__ . join ("\n", map {"<li><a href='#' data-value='$_'>$_" . ($_ eq $atts{selected_value} ? "class='acti +ve'":"") ."</a></li>"} @{$atts{values}}) . "</ul></div>\n"; } 1; # End of BootstrapHelper class
Yes - I realise it lacks documentation - but I'm hoping the code is clear enough to identify calling protocol.

        "Think of how stupid the average person is, and realize half of them are stupider than that." - George Carlin


In reply to Re: How To Use Bootstrap Code in Perl Script? by NetWallah
in thread How To Use Bootstrap Code in Perl Script? by glennpm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.