Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Catalyst::VIew::TT - format an object

by chrestomanci (Priest)
on Jun 27, 2011 at 21:08 UTC ( #911617=note: print w/replies, xml ) Need Help??

in reply to Catalyst::VIew::TT - format an object

Why do you want to use TT Filter?

The way I would approach this problem would be to add some methods to your Bio::Seq class that return html to pretty print your sequence. That way your template just becomes:

The sequence is:[% bio_seq.seq_pretty_display %]

This will have the effect of moving the pretty printing code into your class where it is easier to test, but breaks the strict MVC paradigm of keeping the View separate from the model and controller.

My answer to any pedant who raises that point, is that perl has always been about being pragmatic and getting things done, rather than blind adherence to a particular design pattern.

Replies are listed 'Best First'.
Re^2: Catalyst::VIew::TT - format an object
by tospo (Hermit) on Jun 27, 2011 at 21:50 UTC
    I don't want to use a filter, I would like to access a method defined in the view class in the view itself. The Bio::Seq class is part of the large BioPerl bundle and I don't want to subclass it (and use the subclass everywhere in my code) just to add a method that really doesn't belong to a class that is all about handling sequence data. What if I want to change the HTML code of the output? I would have to do that in My::Bio::Seq and then what if I use this in more than one web app and I want different rendering of the seq features? I don't think that would be a good idea for the same reason that you wouldn't want to provide a "to_html" method to every DBIx result set class.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://911617]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-09-24 01:28 GMT
Find Nodes?
    Voting Booth?
    Eventually, "covfefe" will come to mean:

    Results (191 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!