Builder::XML - Building block for XML
Version 0.06
Please look at Builder docs. This currently contains the necessary synopsis & description for Builder::XML. At some point in future it will be moved here and Builder docs will be replaced with something more generic.
See above.
Here are Builder::XML parameter contexts....
no parameters => produces a closed tag
$xm->br; # => <br />
first parameter is a hashref => attributes
$xm->span( { id => 'mydiv', class => 'thisClass' }, 'some content' ); # => <span class="thisClass" id="mydiv">some content</span>
parameter(s) are a anon sub or code ref --> callback
$xm->ul( { class => 'list' }, sub { for my $numb qw/one two three/ { $xm->li( $numb ); } }); # => <ul class="list"><li>one</li><li>two</li><li>three</li></ul>
parameter(s) are content => element text
$xm->p( 'one', 'two', 'and three' ); # => <p>one two and three</p>
parameter(s) are Builder blocks or content => nesting
$xm->p( 'one', $xm->span( 'two' ), 'and three' ); # => <p>one <span>two</span> and three</p> # NB. THIS DOESN'T WORK YET... unless first param is an object # Workaround - use __say__ method around text like so... # # $xm->p( $xm->__say__('one'), $xm->span( 'two' ), 'and three' ); # # This needs "fixing" for HTML usage
parameter(s) are Builder blocks within builder blocks => nesting ad-infinitum
$xm->div( $xm->div( xm->span( 'hi there'), ), ); # => <div><div><span>hi there</span></div></div>
TODO: XML entities not implemented
TODO: invalid method calls... $xm->flip-flop, $xm->DESTROY, $xm->AUTOLOAD
TODO: Fix / workaround for attribute ordering
None.
All methods are prefix/postfixed with __ so that ambigious method calls wont clash and can be turned successfully into XML elements.
Below is a complete list of defined methods in Builder::XML. NB. Most of these are private methods and only listing here for reference.
Private.
This is the contructor called by the Builder object when creating a block...
$xm = $builder->block( 'Builder::XML' );
All arguments are passed from Builder->block method straight to Builder::XML->__new__
Will immediately render the building block. Can be useful in some cases...
# provide example here of it working # and then provide example of what can go wrong!
...but recommend $builder->render for best practise.
Private
Wraps content in <![CDATA[ ]]> element. Useful for quick ditties like....
$xm->span( $xm->__cdata__( 'yada yada' ) ); # => <span><!CDATA[yada yada]]></span>
But for best practise you probably still find building a block more useful in the long run...
my $xm = $builder->block( 'Builder::XML', { cdata => 1 } ); $xm->span( 'yada yada' );
PRIVATE - used with __cdata__
Really a Private method but as mentioned in Gotchas it can be useful for working around some implementation issues.
Used in method to XML element resolution.
Therefore at present AUTOLOAD cannot be used as a XML element.
Standard POOP!
Therefore at present DESTROY cannot be used as a XML element.
Barry Walsh <draegtun at cpan.org>
<draegtun at cpan.org>
Please report any bugs or feature requests to bug-builder at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Builder. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-builder at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Builder::XML
You can also look for information at: Builder
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Builder
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Builder
CPAN Ratings
http://cpanratings.perl.org/d/Builder
Search CPAN
http://search.cpan.org/dist/Builder/
Copyright 2008-2013 Barry Walsh (Draegtun Systems Ltd | http://www.draegtun.com), all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Builder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Builder
CPAN shell
perl -MCPAN -e shell install Builder
For more information on module installation, please visit the detailed CPAN module installation guide.