
marvin at rectangular
Feb 26, 2008, 9:36 PM
Post #1 of 4
(1172 views)
Permalink
|
|
Re: Subclassable Highlighter
|
|
Father Chrysostomos wrote in reply: > > How about this instead? > > > > * Eliminate Encoder, Formatter, SimpleHTMLEncoder, and > > SimpleHTMLFormatter. > > * Add public encode() and highlight() methods to Highlighter. > > > > sub encode { return encode_entities( $_[1] ) } > > sub highlight { return '<strong>' . $_[1] . '</strong>' } > > Actually, I think that’s worse than the current system. If I wanted > simply to override the default HTML tags, I’d be much more comfortable > with create an object than a class. OK, I can understand that. How about if we change highlight() to use variables which are settable via accessors? __PACKAGE__->ready_get_set(qw( pre_tag post_tag )); sub highlight { "$pre_tag{$$self}$_[1]$post_tag{$$self}" } I'd really like to kill off those four classes. And putting the highlighting functionality into a method named "highlight" makes more sense than farming it out to a class called "Formatter" (so named because it can't be "Highlighter"). Marvin Humphrey Rectangular Research http://www.rectangular.com/ _______________________________________________ KinoSearch mailing list KinoSearch [at] rectangular http://www.rectangular.com/mailman/listinfo/kinosearch
|