![]() |
![]()
| ![]() |
![]()
NAMEHTML::Declare - For When Template Systems Are Too Huge And Heredocs Too MessyVERSIONversion 2.6SYNOPSIS# Import all constructors use HTML::Declare ':all'; # A simple hello world print HTML { _ => [ HEAD { _ => TITLE { _ => 'Hello World!' } }, BODY { _ => 'Hello World!' } ] }; # Import specific constructors use HTML::Declare qw/DIV A/; # A simple anchor nested in a div my $tree = DIV { _ => [ A { href => 'http://127.0.0.1', _ => '<< Home Sweet Home!' } ] }; print "$tree"; DESCRIPTIONA very simple micro language to generate HTML.This is not a real template system like Template or HTML::Mason, it's just a simple (and fun) way to avoid those messy heredocs. ;) METHODSHTML::Declare instances have the following methods.newas_htmlattributeschildrentagFUNCTIONSAll exported functions work the same, they expect a hashref as first argument which contains attributes for the tag to generate.The special attribute _ contains the content for the tag. The content may be a single string (in this case entities are auto encoded), a arrayref containing strings that shouldn't be encoded or HTML::Declare instances. <TAG> { attribute => 'value' } DIV { id => 'foo', _ => 'lalala<<encode me>>' } DIV { id => 'link' _ => [ '<b>Don't encode me!</b>' ] } DIV { _ => [ A { href => 'http://127.0.0.1', _ => 'Home!' } ] } DIV { _ => [ A { href => 'http://host', _ => H1 { _ => 'Test' } } ] } AABBRACRONYMADDRESSAREABBASEBDOBIGBLOCKQUOTEBODYBRBUTTONCAPTIONCITECODECOLCOLGROUPDDDELDIVDFNDLDTEMFIELDSETFORMFRAMEFRAMESETH1H2H3H4H5H6HEADHRHTMLIIFRAMEIMGINPUTINSKBDLABELLEGENDLILINKMAPMETANOFRAMESNOSCRIPTOBJECTOLOPTGROUPOPTIONPPARAMPREQSAMPSCRIPTSELECTSMALLSPANSTRONGSTYLESUBSUPTABLETAGTBODYTDTEXTAREATFOOTTHTHEADTITLETRTTULVARTHANK YOUTatsuhiko MiyagawaAUTHORSebastian Riedel, "sri@oook.de"COPYRIGHT AND LICENSEThis software is copyright (c) 2017 by Sebastian Riedel, C.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|