Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

JavaScript::Code::Block
A JavaScript Block Element

JavaScript::Code::Block - A JavaScript Block Element


NAME

JavaScript::Code::Block - A JavaScript Block Element


DESCRIPTION

A block element in javascript is a collection of javascript elements enclosed in brakets.

Example:


    {   // a block starts

        var a = 42;

        var b = "21 is just half the truth.";

        { // another block starts

            // ...

        } // another block ends

    }   // a block ends



=head1 SYNOPSIS

    #!/usr/bin/perl

    use strict;

    use warnings;

    use JavaScript::Code::Block;

    use JavaScript::Code::Variable;

    my $block1 = JavaScript::Code::Block->new();

    my $var1   = JavaScript::Code::Variable->new( name => 'a', value => "Var 1!" );

    my $var2   = JavaScript::Code::Variable->new()->name('b')->value("Var 2!");

    my $block2 = JavaScript::Code::Block->new();

    my $var3   = JavaScript::Code::Variable->new()->name('c')->value("Var 3!");

    $block1->add( $var1 );

    $block1->add( $var2 )->add( $block2->add( $var3 ) );

    $block1->add( JavaScript::Code::Variable->new()->name('d')->value(42) );

    print $block1->output;


METHODS

new

$self->add( $element | \@elements )

Adds one or more new element(s) to the block.

$self->add_variable( %args | \%args )

Creates a variable using the arguments and adds it to the the block.

Returns a the JavaScript::Code::Variable manpage object.

$self->add_function( %args | \%args )

Creates a function using the arguments and adds it to the the block.

Returns a the JavaScript::Code::Function manpage object.

$self->elements( )

Returns a ref-array of all added elements.

$self->output( )

Returns the javascript code for the block.


SEE ALSO

the JavaScript::Code manpage


AUTHOR

Sascha Kiefer, esskar@cpan.org


LICENSE

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

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy