Rob Kinyon <[EMAIL PROTECTED]> writes:
> Terrence -
>
> First off, excellent article on the dangers of wanting to "make
> it cool". I mean, what's cooler than writing your own compiler?? :-)
It is certainly addictive. I can't wait to sit down for another 2-3
hours of solid hacking.
>
> Question about HTML::Seamstress: What happens if I have two <span
> id="date"> in my document? What does get_date() do?
Answer 1: get_date will perform this method
$tree->look_down(id => 'date');
Per the HTML::Element docs, such a method returns the first element
found in the scalar context. So it would return the first subtree whose root
node had "date" as an id attribute
Answer 2: Per the HTML specifications, it is illegal to have two
different elements with the same value for the id attribute. So, in a
validating situation, such HTML would never make the cut.
However, you have got me thinking. I have gotten pretty used to
writing test cases for all of the various methods. I use
HTML::PrettyPrinter to dump a file of expected output for given
input. I may create a hello_world.t test directory with a pre-made test suite
for each template file. Though I doubt most people would take
advantage of such a suite.
>
> Also, wouldn't it be possible to provide a convenience function of
> foo() that was, essentially, {
> (+shift)->get_foo()->replace_content(@_) } ?
Yes, the most common templating act is substitution. So,
$tree->date->($value)
will be a shortcut for
$tree->get_date->replace_content($value)
All other templating acts will be called "longhand", e.g.
$tree->get_$id->$library_method(@args)
where $library_method is a method such as highlander(), iter(),
dual_iter(), and any other method that exists in HTML::Element or
HTML::Element::Library (to be uploaded).
--
Carter's Compass: I know I'm on the right track when,
by deleting something, I'm adding functionality.
_______________________________________________
sw-design mailing list
[email protected]
http://metaperl.com/cgi-bin/mailman/listinfo/sw-design