HTML-Obj2HTML
view release on metacpan or search on metacpan
# NAME
HTML::Obj2HTML - Create HTML from a arrays and hashes
# SYNOPSYS
use HTML::Obj2HTML (components => 'path/to/components', default_currency => 'GBP', mode => 'XHTML', warn_on_unknown_tag => 1, html_fromarrayref_format => 0)
- `components`
This is the relative path from the current working directory to components.
Obj2HTML will find all \*.po files and automatically register elements that when
called within your object executes the file. (See `fetch()`);
Note, you can change the extension searched for with an import argument:
use HTML::Obj2HTML file_extension => ".po"
- `default_currency`
Which currency to format output for when encountering the built in `currency`
element.
- `mode`
XHTML or HTML
- `warn_on_unknown_tag`
Whether or not to print a warning to STDERR (using carp) when encountering an
element that doesn't look like an HTML element, or registered extension element
- `html_fromarrayref_format`
This module accepts two formats for conversion; one is an HTML::FromArrayref
style arrayref, one is a variation. Differences are noted below.
## Usage
set_opt('opt-name','value');
set_dictionary(\%dictionary);
add_dictionary_items(\%dictionary_items);
set_snippet('snippet-name', \@Obj2HTMLItems);
register_extension('element-name', \%definition);
$result_html = gen(\@Obj2HTMLItems);
An Obj2HTML arrayref is a structure that when processed is turned into HTML.
Without HTML::FromArrayref format eanbled, it looks like this:
[
doctype => "HTML",
html => [
head => [
script => { ... },
],
body => { class => 'someclass', _ => [
h1 => "Test page",
p => "This is my test page!"
]}
]
];
## Builtin Features
- Add a snippet with \_snippet-name syntax
[
div => _snippet
]
- Execute a subroutine at generate time
[
div => \&generate_something
]
- Ignore things that don't look like elements at all; treat them like content
[
p => [
"I really ",
b => "really",
" want an ice-cream"
]
]
( run in 1.444 second using v1.01-cache-2.11-cpan-119454b85a5 )