From: Matt S Trout Date: Wed, 17 Mar 2010 21:34:00 +0000 (+0000) Subject: first cut at docs for Zoom.pm X-Git-Tag: release_0.009004~69 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=1c4455ae8e6f536e9f9bca403be66a5141886556 first cut at docs for Zoom.pm --- diff --git a/lib/HTML/Zoom.pm b/lib/HTML/Zoom.pm index 0ae18d2..dac8bd7 100644 --- a/lib/HTML/Zoom.pm +++ b/lib/HTML/Zoom.pm @@ -76,7 +76,8 @@ sub memoize { } sub with_filter { - my ($self, $selector, $filter) = @_; + my $self = shift->_self_or_new; + my ($selector, $filter) = @_; my $match = $self->parse_selector($selector); $self->_with({ filters => [ @{$self->{filters}||[]}, [ $match, $filter ] ] @@ -84,7 +85,8 @@ sub with_filter { } sub select { - my ($self, $selector) = @_; + my $self = shift->_self_or_new; + my ($selector) = @_; my $match = $self->parse_selector($selector); return HTML::Zoom::MatchWithoutFilter->construct( $self, $match, $self->zconfig->filter_builder, @@ -94,7 +96,7 @@ sub select { # There's a bug waiting to happen here: if you do something like # # $zoom->select('.foo') -# ->remove_attribute({ class => 'foo' }) +# ->remove_attribute(class => 'foo') # ->then # ->well_anything_really # @@ -206,6 +208,491 @@ will produce: =end testinfo -=head1 SOMETHING ELSE +=head1 DANGER WILL ROBINSON + +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 politician's ego in the API design that I haven't spotted yet there may be +a bit of breakage between here and 1.0. Hopefully not though. Appendages +crossed and all that. + +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 to cut a first real release. + +=head1 DESCRIPTION + +HTML::Zoom is a lazy, stream oriented, streaming capable, mostly functional, +CSS selector based semantic templating engine for HTML and HTML-like +document formats. + +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: + +=head2 JQUERY ENVY + +HTML::Zoom is the cure for JQuery envy. When your javascript guy pushes a +piece of data into a document by doing: + + $('.username').replaceAll(username); + +In HTML::Zoom one can write + + $zoom->select('.username')->replace_content($username); + +which is, I hope, almost as clear, hampered only by the fact that Zoom can't +assume a global document and therefore has nothing quite so simple as the +$() function to get the initial selection. + +L implements a subset of the JQuery selector +specification, and will continue to track that rather than the W3C standards +for the forseeable future on grounds of pragmatism. Also on grounds of their +spec is written in EN_US rather than EN_W3C, and I read the former much better. + +I am happy to admit that it's very, very much a subset at the moment - see the +L POD for what's currently there, and expect more +and more to be supported over time as we need it and patch it in. + +=head2 CLEAN TEMPLATES + +HTML::Zoom is the cure for messy templates. How many times have you looked at +templates like this: + +
+ [% FOREACH field IN fields %] + + + [% END %] +
+ +and despaired of the fact that neither the HTML structure nor the logic are +remotely easy to read? Fortunately, with HTML::Zoom we can separate the two +cleanly: + +
+