Mojito
view release on metacpan or search on metacpan
bench/selectors.pl view on Meta::CPAN
<li class='indexItem indexItem1'><a href='#AUTHORS'>AUTHORS</a>
<li class='indexItem indexItem1'><a href='#LICENSE'>LICENSE</a>
</ul>
</div>
</div>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<p>HTML::Zoom - selector based streaming template engine</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<pre class="prettyprint"> use HTML::Zoom;
my $template = <<HTML;
<html>
<head>
bench/selectors.pl view on Meta::CPAN
>DANGER WILL ROBINSON <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<p>This is a 0.9 release. That means that I'm fairly happy the API isn't going to change in surprising and upsetting ways before 1.0 and a real compatibility freeze. But it also means that if it turns out there's a mistake the size of a p...
<p>Worse still, the rest of the distribution isn't documented yet. I'm sorry. I suck. But lots of people have been asking me to ship this, docs or no, so having got this class itself at least somewhat documented I figured now was a good time ...
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<p>HTML::Zoom is a lazy, stream oriented, streaming capable, mostly functional, CSS selector based semantic templating engine for HTML and HTML-like document formats.</p>
<p>Which is, on the whole, a bit of a mouthful. So let me step back a moment and explain why you care enough to understand what I mean:</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="JQUERY_ENVY"
>JQUERY ENVY</a></h2>
<p>HTML::Zoom is the cure for JQuery envy. When your javascript guy pushes a piece of data into a document by doing:</p>
<pre class="prettyprint"> $('.username').replaceAll(username);</pre>
bench/selectors.pl view on Meta::CPAN
<p>works on both HTML::Zoom objects themselves and HTML::Zoom stream objects and shares sufficient of the implementation that you can generally forget the difference - barring the fact that a stream already has state attached so things like to_fh are...
<h2><a class='u' href='#___top' title='click to go to top of document'
name="POP!_GOES_THE_WEASEL"
>POP! GOES THE WEASEL</a></h2>
<p>... and by Weasel, I mean layout.</p>
<p>HTML::Zoom's filehandle object supports an additional event key, 'flush', that is transparent to the rest of the system but indicates to the filehandle object to end a getline operation at that point and return the HTML so far.</p>
<p>This means that in an environment where streaming output is available, such as a number of the <a href="/perldoc?Plack" class="podlinkpod"
>Plack</a> PSGI handlers, you can add the flush key to an event in order to ensure that the HTML generated so far is flushed through to the browser right now. This can be especially useful if you know you're about to call a web service or a poten...
<p>This is currently exposed by the 'flush_before' option to the collect filter, which incidentally also underlies the replace and repeat filters, so to indicate we want this behaviour to happen before a query is executed we can write somethi...
<pre class="prettyprint"> $zoom->select('.item')->repeat(sub {
if (my $row = $db_thing->next) {
return sub { $_->select('.item-name')->replace_content($row->name) }
} else {
return
}
bench/selectors.pl view on Meta::CPAN
<p>If you do something more clever than that, or find yourself overriding things in your ZConfig a lot, please please tell us about it via one of the means mentioned under <a href="#SUPPORT" class="podlinkpod"
>"SUPPORT"</a>.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="SEMANTIC_DIDACTIC"
>SEMANTIC DIDACTIC</a></h2>
<p>Some will argue that overloading CSS selectors to do data stuff is a terrible idea, and possibly even a step towards the "Concrete Javascript" pattern (which I abhor) or Smalltalk's Morphic (which I ignore, except for the part where it...
<p>To which I say, "eh", "meh", and possibly also "feh". If it really upsets you, either use extra classes for this (and remove them afterwards) or use special fake elements or, well, honestly, just use something different. <a...
>Template::Semantic</a> provides a similar idea to zoom except using XPath and XML::LibXML transforms rather than a lightweight streaming approach - maybe you'd like that better. Or maybe you really did want <a href="/perldoc?Template" class="pod...
>Template Toolkit</a> after all. It is still damn good at what it does, after all.</p>
<p>So far, however, I've found that for new sites the designers I'm working with generally want to produce nice semantic HTML with classes that represent the nature of the data rather than the structure of the layout, so sharing them as a com...
<p>In the absence of any evidence that overloading CSS selectors has killed children or unexpectedly set fire to grandmothers - and given microformats have been around for a while there's been plenty of opportunity for octagenarian combustion - I...
<h2><a class='u' href='#___top' title='click to go to top of document'
name="GET_THEE_TO_A_SUMMARY!"
>GET THEE TO A SUMMARY!</a></h2>
<p>Erm. Well.</p>
<p>HTML::Zoom is a lazy, stream oriented, streaming capable, mostly functional, CSS selector based semantic templating engine for HTML and HTML-like document formats.</p>
<p>But I said that already. Although hopefully by now you have some idea what I meant when I said it. If you didn't have any idea the first time. I mean, I'm not trying to call you stupid or anything. Just saying that maybe it wasn't tota...
<p>Er.</p>
<p>Maybe we should just move on to the method docs.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
bench/zoom.pl view on Meta::CPAN
use HTML::Zoom;
my $html_frag = '<section id=view_area></section>';
my $doc;
#my $zoom = HTML::Zoom->new;
my $zoom_view = HTML::Zoom->from_html($html_frag)->select('#view_area');
my $count = 10000;
my $big_chunk =<<'EOH';
Some will argue that overloading CSS selectors to do data stuff is a terrible idea, and possibly even a step towards the "Concrete Javascript" pattern (which I abhor) or Smalltalk's Morphic (which I ignore, except for the part where it keeps remindin...
To which I say, "eh", "meh", and possibly also "feh". If it really upsets you, either use extra classes for this (and remove them afterwards) or use special fake elements or, well, honestly, just use something different. Template::Semantic provides a...
So far, however, I've found that for new sites the designers I'm working with generally want to produce nice semantic HTML with classes that represent the nature of the data rather than the structure of the layout, so sharing them as a common interfa...
In the absence of any evidence that overloading CSS selectors has killed children or unexpectedly set fire to grandmothers - and given microformats have been around for a while there's been plenty of opportunity for octagenarian combustion - I'd sugg...
EOH
my $result = cmpthese(
$count,
{
bench/zoom.pl view on Meta::CPAN
<li class='indexItem indexItem1'><a href='#AUTHORS'>AUTHORS</a>
<li class='indexItem indexItem1'><a href='#LICENSE'>LICENSE</a>
</ul>
</div>
</div>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<p>HTML::Zoom - selector based streaming template engine</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<pre class="prettyprint"> use HTML::Zoom;
my $template = <<HTML;
<html>
<head>
bench/zoom.pl view on Meta::CPAN
>DANGER WILL ROBINSON <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<p>This is a 0.9 release. That means that I'm fairly happy the API isn't going to change in surprising and upsetting ways before 1.0 and a real compatibility freeze. But it also means that if it turns out there's a mistake the size of a p...
<p>Worse still, the rest of the distribution isn't documented yet. I'm sorry. I suck. But lots of people have been asking me to ship this, docs or no, so having got this class itself at least somewhat documented I figured now was a good time ...
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
<p>HTML::Zoom is a lazy, stream oriented, streaming capable, mostly functional, CSS selector based semantic templating engine for HTML and HTML-like document formats.</p>
<p>Which is, on the whole, a bit of a mouthful. So let me step back a moment and explain why you care enough to understand what I mean:</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="JQUERY_ENVY"
>JQUERY ENVY</a></h2>
<p>HTML::Zoom is the cure for JQuery envy. When your javascript guy pushes a piece of data into a document by doing:</p>
<pre class="prettyprint"> $('.username').replaceAll(username);</pre>
bench/zoom.pl view on Meta::CPAN
<p>works on both HTML::Zoom objects themselves and HTML::Zoom stream objects and shares sufficient of the implementation that you can generally forget the difference - barring the fact that a stream already has state attached so things like to_fh are...
<h2><a class='u' href='#___top' title='click to go to top of document'
name="POP!_GOES_THE_WEASEL"
>POP! GOES THE WEASEL</a></h2>
<p>... and by Weasel, I mean layout.</p>
<p>HTML::Zoom's filehandle object supports an additional event key, 'flush', that is transparent to the rest of the system but indicates to the filehandle object to end a getline operation at that point and return the HTML so far.</p>
<p>This means that in an environment where streaming output is available, such as a number of the <a href="/perldoc?Plack" class="podlinkpod"
>Plack</a> PSGI handlers, you can add the flush key to an event in order to ensure that the HTML generated so far is flushed through to the browser right now. This can be especially useful if you know you're about to call a web service or a poten...
<p>This is currently exposed by the 'flush_before' option to the collect filter, which incidentally also underlies the replace and repeat filters, so to indicate we want this behaviour to happen before a query is executed we can write somethi...
<pre class="prettyprint"> $zoom->select('.item')->repeat(sub {
if (my $row = $db_thing->next) {
return sub { $_->select('.item-name')->replace_content($row->name) }
} else {
return
}
bench/zoom.pl view on Meta::CPAN
<p>If you do something more clever than that, or find yourself overriding things in your ZConfig a lot, please please tell us about it via one of the means mentioned under <a href="#SUPPORT" class="podlinkpod"
>"SUPPORT"</a>.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="SEMANTIC_DIDACTIC"
>SEMANTIC DIDACTIC</a></h2>
<p>Some will argue that overloading CSS selectors to do data stuff is a terrible idea, and possibly even a step towards the "Concrete Javascript" pattern (which I abhor) or Smalltalk's Morphic (which I ignore, except for the part where it...
<p>To which I say, "eh", "meh", and possibly also "feh". If it really upsets you, either use extra classes for this (and remove them afterwards) or use special fake elements or, well, honestly, just use something different. <a...
>Template::Semantic</a> provides a similar idea to zoom except using XPath and XML::LibXML transforms rather than a lightweight streaming approach - maybe you'd like that better. Or maybe you really did want <a href="/perldoc?Template" class="pod...
>Template Toolkit</a> after all. It is still damn good at what it does, after all.</p>
<p>So far, however, I've found that for new sites the designers I'm working with generally want to produce nice semantic HTML with classes that represent the nature of the data rather than the structure of the layout, so sharing them as a com...
<p>In the absence of any evidence that overloading CSS selectors has killed children or unexpectedly set fire to grandmothers - and given microformats have been around for a while there's been plenty of opportunity for octagenarian combustion - I...
<h2><a class='u' href='#___top' title='click to go to top of document'
name="GET_THEE_TO_A_SUMMARY!"
>GET THEE TO A SUMMARY!</a></h2>
<p>Erm. Well.</p>
<p>HTML::Zoom is a lazy, stream oriented, streaming capable, mostly functional, CSS selector based semantic templating engine for HTML and HTML-like document formats.</p>
<p>But I said that already. Although hopefully by now you have some idea what I meant when I said it. If you didn't have any idea the first time. I mean, I'm not trying to call you stupid or anything. Just saying that maybe it wasn't tota...
<p>Er.</p>
<p>Maybe we should just move on to the method docs.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS <img alt='^' src='http://st.pimg.net/tucs/img/up.gif'></a></h1>
( run in 0.247 second using v1.01-cache-2.11-cpan-4d50c553e7e )