The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Builder - Build XML, HTML, CSS and other outputs in blocks

VERSION

Version 0.01

SYNOPSIS

Example using just one building block (for now!)....

    use Builder;


    my $builder = Builder->new();
    
    my $xm = $builder->block( 'Builder::XML' );


    $xm->body(
        $xm->div( { id => 'mydiv' }, 
            $xm->bold( 'hello' ), 
            $xm->em( 'world' ) 
        );
    );


    say $builder->render;


    # will produce =>
    # <body><div id="mydiv"><bold>hello</bold><em>world</em></div></body>

DESCRIPTION

TBD... add multiple blocks & sub (coderef) examples.

TBD... add Builder non-OO example (once back in codebase!)

EXPORT

Nothing (at this moment!)

METHODS

new

Constructor. Currently no args are used.

    my $builder = Builder->new();

block

Create a block. First arg is the block to use, for eg. 'Builder::XML'. Second arg is a hashref (or it will be!)

    my $builder = Builder->new();

    my $xm = $builder->block( 'Builder::XML', cdata => 1 );       # v 0.01

    my $xm = $builder->block( 'Builder::XML', { cdata => 1 } );   # v 0.02 onwards

For options that can be passed as args please see relevant builder documentation.

render

Renders all the blocks for the requested builder stack returning the information.

    my $output = $builder->render;

flush

The render method will automatically flush the builder stack. Unlikely this will be any use externally!

    $builder->flush;     # there goes all the blocks just built ;-(

AUTHOR

Barry Walsh <draegtun at cpan.org>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Builder

You can also look for information at: http://github.com/draegtun/builder

ACKNOWLEDGEMENTS

SEE ALSO

Other Builder::* modules:

Builder::XML

Similar CPAN modules:

Class::XML, XML::Generator

Builder Source Code

Can be (shortly!) found on GitHub at http://github.com/draegtun/builder/tree/master

DISCLAIMER

This is (near) beta software. I'll strive to make it better each and every day!

However I accept no liability whatsoever should this software do what you expected ;-)

COPYRIGHT & LICENSE

Copyright 2008 Barry Walsh (Draegtun Systems Ltd), all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.