NAME DSL::HTML - Declarative DSL(domain specific language) for writing HTML templates within perl. DESCRIPTION Templating systems suck. This sucks less. In most cases a templating system lets you write html files with embedded logic. The embedded logic can be a template specific language, or it can let you embed code from the projects programming language. An alternative that has been played with is constructing the HTML directly in your application language. In most cases this sucks more. OOP, where objects are built and then associated via method calls is NOT a friendly way to build a complex tree. DSL::HTML takes the alternative approach, but does it in a significantly more elegent way. Instead of forcing you to construct objects and build a tree manually via methods, you define the tree via nested subroutines. This is sort of a functional approach to tree building. EARLY VERSION WARNING THIS IS AN EARLY VERSION! Basically I have not decided 100% that the API will remain as-is (though it likely will not change much). I am also embarrased to admit that this code is very poorly tested (Yes, this is more embarrasing considering I wrote Fennec). BENEFITS The template language is perl There is no embedded template language, your logic is all in perl, you treat all tags like perl objects. The nested block syntax allows this while also saving you from the PITA of direct object manipulation; that is you do not need to say "$tag->insert(Tag->new)" or similar. No need to hand-write html Hand-written HTML is easy to screw up. You might forget to close a tag, or nest things improperly. The nature of browsers it to try to make it work anyway, so you can sometimes spend hours debugging broken html. Syntax checking is done by perl The nested-blok syntax is checked by perl. If you make a syntax error, or a typo, perl will typically catch your mistake when you try to build the package. Templates and tags are built like subroutines This means you call your template with argumnets similar to how you can any function with arguments. Templates can be imported/exported between modules. You can create perl modules that are simply template libraries, other modules can load these libraries to gain access to the templates. SYNOPSYS # Note: This brings in an import() method. # See the EXPORTS - import() section later in this doc for more info. use DSL::HTML; template my_template { my @options = @_; # The lexical variable '$tag' is defined for you automatically and is a # reference to the current tag on the stack (usually ) $tag->attr( foo => 'bar' ); css 'my/css/file.css'; # Goes to the header tag h1 { "Welcome!" } tag h2 { "Choices:" } # Tags nest naturally, here is a