.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mojolicious::Plugin::TagHelpers 3pm" .TH Mojolicious::Plugin::TagHelpers 3pm "2012-09-05" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojolicious::Plugin::TagHelpers \- Tag helpers plugin .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # Mojolicious \& $self\->plugin(\*(AqTagHelpers\*(Aq); \& \& # Mojolicious::Lite \& plugin \*(AqTagHelpers\*(Aq; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojolicious::Plugin::TagHelpers is a collection of \s-1HTML5\s0 tag helpers for Mojolicious. .PP Most form helpers can automatically pick up previous input values and will show them as default. You can also use \&\*(L"param\*(R" in Mojolicious::Plugin::DefaultHelpers to set them manually and let necessary attributes always be generated automatically. .PP .Vb 4 \& % param country => \*(Aqgermany\*(Aq unless param \*(Aqcountry\*(Aq; \& <%= radio_button country => \*(Aqgermany\*(Aq %> Germany \& <%= radio_button country => \*(Aqfrance\*(Aq %> France \& <%= radio_button country => \*(Aquk\*(Aq %> UK .Ve .PP This is a core plugin, that means it is always enabled and its code a good example for learning how to build new plugins, you're welcome to fork it. .SH "HELPERS" .IX Header "HELPERS" Mojolicious::Plugin::TagHelpers implements the following helpers. .ie n .SS """base_tag""" .el .SS "\f(CWbase_tag\fP" .IX Subsection "base_tag" .Vb 1 \& %= base_tag .Ve .PP Generate portable \f(CW\*(C`base\*(C'\fR tag refering to the current base \s-1URL\s0. .PP .Vb 1 \& .Ve .ie n .SS """check_box""" .el .SS "\f(CWcheck_box\fP" .IX Subsection "check_box" .Vb 2 \& %= check_box employed => 1 \& %= check_box employed => 1, id => \*(Aqfoo\*(Aq .Ve .PP Generate checkbox input element. Previous input values will automatically get picked up and shown as default. .PP .Vb 2 \& \& .Ve .ie n .SS """file_field""" .el .SS "\f(CWfile_field\fP" .IX Subsection "file_field" .Vb 2 \& %= file_field \*(Aqavatar\*(Aq \& %= file_field \*(Aqavatar\*(Aq, id => \*(Aqfoo\*(Aq .Ve .PP Generate file input element. .PP .Vb 2 \& \& .Ve .ie n .SS """form_for""" .el .SS "\f(CWform_for\fP" .IX Subsection "form_for" .Vb 10 \& %= form_for login => (method => \*(AqPOST\*(Aq) => begin \& %= text_field \*(Aqfirst_name\*(Aq \& %= submit_button \& % end \& %= form_for login => {foo => \*(Aqbar\*(Aq} => (method => \*(AqPOST\*(Aq) => begin \& %= text_field \*(Aqfirst_name\*(Aq \& %= submit_button \& % end \& %= form_for \*(Aq/login\*(Aq => (method => \*(AqPOST\*(Aq) => begin \& %= text_field \*(Aqfirst_name\*(Aq \& %= submit_button \& % end \& %= form_for \*(Aqhttp://kraih.com/login\*(Aq => (method => \*(AqPOST\*(Aq) => begin \& %= text_field \*(Aqfirst_name\*(Aq \& %= submit_button \& % end .Ve .PP Generate portable form for route, path or \s-1URL\s0. For routes that allow \f(CW\*(C`POST\*(C'\fR but not \f(CW\*(C`GET\*(C'\fR, a \f(CW\*(C`method\*(C'\fR attribute will be automatically added. .PP .Vb 10 \&
\& \& \&
\&
\& \& \&
\&
\& \& \&
\&
\& \& \&
.Ve .ie n .SS """hidden_field""" .el .SS "\f(CWhidden_field\fP" .IX Subsection "hidden_field" .Vb 2 \& %= hidden_field foo => \*(Aqbar\*(Aq \& %= hidden_field foo => \*(Aqbar\*(Aq, id => \*(Aqbar\*(Aq .Ve .PP Generate hidden input element. .PP .Vb 2 \& \& .Ve .ie n .SS """image""" .el .SS "\f(CWimage\fP" .IX Subsection "image" .Vb 2 \& %= image \*(Aq/images/foo.png\*(Aq \& %= image \*(Aq/images/foo.png\*(Aq, alt => \*(AqFoo\*(Aq .Ve .PP Generate image tag. .PP .Vb 2 \& \& Foo .Ve .ie n .SS """input_tag""" .el .SS "\f(CWinput_tag\fP" .IX Subsection "input_tag" .Vb 3 \& %= input_tag \*(Aqfirst_name\*(Aq \& %= input_tag first_name => \*(AqDefault name\*(Aq \& %= input_tag \*(Aqemployed\*(Aq, type => \*(Aqcheckbox\*(Aq .Ve .PP Generate form input element. Previous input values will automatically get picked up and shown as default. .PP .Vb 3 \& \& \& .Ve .ie n .SS """javascript""" .el .SS "\f(CWjavascript\fP" .IX Subsection "javascript" .Vb 4 \& %= javascript \*(Aq/script.js\*(Aq \& %= javascript begin \& var a = \*(Aqb\*(Aq; \& % end .Ve .PP Generate portable script tag for \f(CW\*(C`Javascript\*(C'\fR asset. .PP .Vb 4 \& .Ve .ie n .SS """link_to""" .el .SS "\f(CWlink_to\fP" .IX Subsection "link_to" .Vb 8 \& %= link_to Home => \*(Aqindex\*(Aq \& %= link_to index => {foo => \*(Aqbar\*(Aq} => (class => \*(Aqlinks\*(Aq) => begin \& Home \& % end \& <%= link_to index => begin %>Home<% end %> \& <%= link_to \*(Aq/path/to/file\*(Aq => begin %>File<% end %> \& <%= link_to \*(Aqhttp://mojolicio.us\*(Aq => begin %>Mojolicious<% end %> \& <%= link_to url_for\->query(foo => \*(Aqbar\*(Aq)\->to_abs => begin %>Retry<% end %> .Ve .PP Generate portable link to route, path or \s-1URL\s0, defaults to using the capitalized link target as content. .PP .Vb 6 \& Home \& Home \& Home \& File \& Mojolicious \& Retry .Ve .ie n .SS """password_field""" .el .SS "\f(CWpassword_field\fP" .IX Subsection "password_field" .Vb 2 \& %= password_field \*(Aqpass\*(Aq \& %= password_field \*(Aqpass\*(Aq, id => \*(Aqfoo\*(Aq .Ve .PP Generate password input element. .PP .Vb 2 \& \& .Ve .ie n .SS """radio_button""" .el .SS "\f(CWradio_button\fP" .IX Subsection "radio_button" .Vb 2 \& %= radio_button country => \*(Aqgermany\*(Aq \& %= radio_button country => \*(Aqgermany\*(Aq, id => \*(Aqfoo\*(Aq .Ve .PP Generate radio input element. Previous input values will automatically get picked up and shown as default. .PP .Vb 2 \& \& .Ve .ie n .SS """select_field""" .el .SS "\f(CWselect_field\fP" .IX Subsection "select_field" .Vb 5 \& %= select_field language => [qw(de en)] \& %= select_field language => [qw(de en)], id => \*(Aqlang\*(Aq \& %= select_field country => [[Germany => \*(Aqde\*(Aq], \*(Aqen\*(Aq] \& %= select_field country => [{Europe => [[Germany => \*(Aqde\*(Aq], \*(Aqen\*(Aq]}] \& %= select_field country => [[Germany => \*(Aqde\*(Aq, class => \*(Aqeurope\*(Aq], \*(Aqen\*(Aq] .Ve .PP Generate select, option and optgroup elements. Previous input values will automatically get picked up and shown as default. .PP .Vb 10 \& \& \& \& \& .Ve .ie n .SS """stylesheet""" .el .SS "\f(CWstylesheet\fP" .IX Subsection "stylesheet" .Vb 4 \& %= stylesheet \*(Aq/foo.css\*(Aq \& %= stylesheet begin \& body {color: #000} \& % end .Ve .PP Generate portable style or link tag for \f(CW\*(C`CSS\*(C'\fR asset. .PP .Vb 4 \& \& .Ve .ie n .SS """submit_button""" .el .SS "\f(CWsubmit_button\fP" .IX Subsection "submit_button" .Vb 2 \& %= submit_button \& %= submit_button \*(AqOk!\*(Aq, id => \*(Aqfoo\*(Aq .Ve .PP Generate submit input element. .PP .Vb 2 \& \& .Ve .ie n .SS """t""" .el .SS "\f(CWt\fP" .IX Subsection "t" .Vb 1 \& %=t div => \*(Aqsome & content\*(Aq .Ve .PP Alias for \f(CW\*(C`tag\*(C'\fR. .PP .Vb 1 \&
some & content
.Ve .ie n .SS """tag""" .el .SS "\f(CWtag\fP" .IX Subsection "tag" .Vb 4 \& %= tag \*(Aqdiv\*(Aq \& %= tag \*(Aqdiv\*(Aq, id => \*(Aqfoo\*(Aq \& %= tag div => \*(Aqsome & content\*(Aq \& <%= tag div => begin %>some & content<% end %> .Ve .PP \&\s-1HTML5\s0 tag generator. .PP .Vb 4 \&
\&
\&
some & content
\&
some & content
.Ve .PP Very useful for reuse in more specific tag helpers. .PP .Vb 3 \& $self\->tag(\*(Aqdiv\*(Aq); \& $self\->tag(\*(Aqdiv\*(Aq, id => \*(Aqfoo\*(Aq); \& $self\->tag(div => sub { \*(AqContent\*(Aq }); .Ve .PP Results are automatically wrapped in Mojo::ByteStream objects to prevent accidental double escaping. .ie n .SS """text_field""" .el .SS "\f(CWtext_field\fP" .IX Subsection "text_field" .Vb 3 \& %= text_field \*(Aqfirst_name\*(Aq \& %= text_field first_name => \*(AqDefault name\*(Aq \& %= text_field first_name => \*(AqDefault name\*(Aq, class => \*(Aquser\*(Aq .Ve .PP Generate text input element. Previous input values will automatically get picked up and shown as default. .PP .Vb 3 \& \& \& .Ve .ie n .SS """text_area""" .el .SS "\f(CWtext_area\fP" .IX Subsection "text_area" .Vb 5 \& %= text_area \*(Aqfoo\*(Aq \& %= text_area foo => \*(AqDefault!\*(Aq, cols => 40 \& %= text_area foo => begin \& Default! \& % end .Ve .PP Generate textarea element. Previous input values will automatically get picked up and shown as default. .PP .Vb 5 \& \& \& .Ve .SH "METHODS" .IX Header "METHODS" Mojolicious::Plugin::TagHelpers inherits all methods from Mojolicious::Plugin and implements the following new ones. .ie n .SS """register""" .el .SS "\f(CWregister\fP" .IX Subsection "register" .Vb 1 \& $plugin\->register($app); .Ve .PP Register helpers in Mojolicious application. .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .