JavaScript::Code::Block - A JavaScript Block Element
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
#!/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;
Adds one or more new element(s) to the block.
Creates a variable using the arguments and adds it to the the block.
Returns a JavaScript::Code::Variable object.
Creates a function using the arguments and adds it to the the block.
Returns a JavaScript::Code::Function object.
Returns a ref-array of all added elements.
Returns the javascript code for the block.
JavaScript::Code
Sascha Kiefer, esskar@cpan.org
esskar@cpan.org
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install JavaScript::Code, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JavaScript::Code
CPAN shell
perl -MCPAN -e shell install JavaScript::Code
For more information on module installation, please visit the detailed CPAN module installation guide.