NAME Catalyst::View::ByCode - Templating using pure Perl code SYNOPSIS # 1) use the helper to create your View myapp_create.pl view ByCode ByCode # 2) inside your Controllers do business as usual: sub index :Path :Args(0) { my ($self, $c) = @_; # unless defined as default_view in your config, specify: $c->stash->{current_view} = 'ByCode'; $c->stash->{title} = 'Hello ByCode'; # if omitted, would default to # controller_namespace / action_namespace .pl $c->stash->{template} = 'hello.pl'; } # 3) create a simple template eg 'root/bycode/hello.pl # REMARK: # use 'c' instead of '$c' # prefer 'stash->{...}' to 'c->stash->{...}' template { html { head { title { stash->{title} }; load Js => 'site.js'; load Css => 'site.css'; }; body { div header.noprint { ul.topnav { li {'home'}; li {'surprise'}; }; }; div content { h1 { stash->{title} }; div { 'hello.pl is running!' }; img(src => '/static/images/catalyst_logo.png'); }; }; }; }; # 274 characters without white space # 4) expect to get this HTML generated: Hello ByCode!

Hello ByCode!

hello.pl is running!
# 453 characters without white space DESCRIPTION `Catalyst::View::ByCode' tries to offer an efficient, fast and robust solution for generating HTML and XHTML markup using standard perl code encapsulating all nesting into code blocks. Instead of typing opening and closing HTML-Tags we simply call a sub named like the tag we want to generate: div { 'hello' } generates:
hello
There is no templating language you will have to learn, no quirks with different syntax rules your editor might not correctly follow and no indentation problems. The whole markup is initially constructed as a huge tree-like structure in memory keeping every reference as long as possible to allow greatest flexibility and enable deferred construction of every building block until the markup is actially requested. Every part of the markup can use almost every type of data with some reasonable behavior during markup generation. Tags Every tag known in HTML (or defined in HTML::Tagset to be precise) gets exported to a template's namespace during its compilation and can be used as expected. However, there are some exceptions which would collide with CORE subs or operators choice generates a