Dan DeBrito > HTML-TagTree-v1.00 > HTML::TagTree

Download:
HTML-TagTree-v1.00.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.0.0   Source  

NAME ^

   HTML::TagTree - An HTML generator via a tree of 'tag' objects.

SYNOPSIS ^

   use HTML::TagTree;

   my $html = HTML::TagTree->new('html');
   my $head = $html->head();
   my $body = $html->body();
   $head->title("This is the Title of Gary's Page, the opening title...");
   $head->meta('', 'name=author CONTENT="Dan DeBrito"');
   $body->div->h1('Hello Dolly');
   my $table = $body->table('', 'width=100% border=1');
   my $row1 = $table->tr();
   $row1->td('cell a');
   $row1->td('cell b');
   $table->tr->td('This is a new row with new cell');  
   $table->tr->td('This is a another new row with new data');

   # Print out the actual HTML
   $html->print_html();
   
   # Put html into a scalar variable
   my $html_source = $html->get_html_text();

   # Force destruction of object tree
   $html->release();

DESCRIPTION ^

      HTLM::TagTrees allows easy building of a tree objects where
      each object represents: 1) a tag 2) its value and 3) any
      tag attributes. Valid HTML is build of the tree via a method call.

FEATURES ^

   Smart quoting of tag parameters:
   Doing something like this:
      $body->div('','id=nav onclick="alert(\"Hello World\"');
   the HTML module will render HTML that looks like:
      <div id="nav" onclick='alert("Hello World")' \>

   Reduce whitespace in your HTML rendering by turning
   on the no_whitespace_flag.
   my $no_whitespace_html_text = $html->get_html_text('',1);
   
   # Or..
   my $indent_level = 0;
   my $no_whitespace_flag = 1;
   print $html_obj->get_html_text($indent_level, $no_whitespace_flag); 

INITIALIZATION ^

      HTML::TagTree->new(tag_name,[value],[attributes])
         Returns a TagTree object

METHODS ^

      Every HTML tag type is an object method.
      $obj->tag_name(content,attributes);
         Returns:
            object for valid creation
            undef if tag_name is not a valid name;
         Arguments:
            content:
               Untagged data that goes in between open and close tag. eg
                  <b>content</b>
               Content my be a Perl scalar, a ref to a scalar, 
               or ref to a subroutine. Dereferencing occurs at the
               time of HTML rendering (via print_html()
               or get_html_text() methods).
            attributes:
               Attributes of this HTML tag.
               Attributes argument may be a Perl scalar, a ref to a scalar,
               or a ref to a subroutine. Dereferencing occurs at the
               time of HTML rendering.
               Example of attributes:
                  'id=first_name name=fn class=str_cl'
      get_html_text()
         Return valid HTML representation of tag tree starting at tab object.
      print_html()
         Prints the valid HTML to STDOUT
      release()
         Destroys all children objects so no objects reference
         this object (and it can be destroyed when it goes out of scope).
      set_valid_tags( tag_names )
         Clears and sets what the valid tag names are for which
         objects can be created.

FUNCTIONS ^

      HTML::TagTree::get_http_header();
         Returns the generic HTTP header:
            "Content-type: text/html\nStatus: 200  OK\n\n";

ABSTRACT ^

      The philosophy of HTML::TagTree is to let you create
      one region of code with lots of business logic 
      for rendering many possible resulting HTML files/output.
      This differs from the approach of using business logic code
      to decide which (of many) HTML template to render.
      So rather than maintaining many HTML templates, you
      maintain a Perl file that does all possible customizations
      of HTML generation.

      This module strives to minimize typing. Object treeing is
      just a simple method call, eg:
         $body->h1->b->i('This is a bold, italic heading');

      HTML::TagTree removes the worries of making simple HTML syntax
      error such as no matching closing tag for an open tag.

VERSION ^

HTML::TagTree version 1.0.

PREREQUISITES ^

No prerequisites.

AUTHOR ^

Dan DeBrito (<ddebrito@gmail.com>)

COPYRIGHT ^

Copyright (c) 2007 - 2011 by Dan DeBrito. All rights reserved.

LICENSE ^

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e., under the terms of the "Artistic License" or the "GNU General Public License".

Please refer to the files "Artistic.txt", "GNU_GPL.txt" and "GNU_LGPL.txt" in this distribution for details!

DISCLAIMER ^

This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the "GNU General Public License" for more details.

syntax highlighting: