plack / Plack

PSGI toolkit and server adapters
http://plackperl.org/
Other
486 stars 214 forks source link

Use methods for HTML/CSS so it's easier to subclass. #693

Closed davorg closed 1 year ago

davorg commented 1 year ago

I wanted to change the HTML/CSS in a subclass of this class, but using lexical variables makes it too hard. I worked around it, but a change like this would make it easier in the future.

miyagawa commented 1 year ago

Do you actually need to subclass for other reasons? Because we can change it to a sub callback then you could supply your custom attributes without creating a subclass.

davorg commented 1 year ago

Well, I'm currently using doing stuff with a subclass (https://github.com/davorg/plack-app-directoryindex) which adds support for index.html to Plack::App::Directory. But I wouldn't need to use that subclass if you merged https://github.com/plack/Plack/pull/654 :-)

davorg commented 1 year ago

Oh wait. Looks like my previous PR has got somewhat corrupted. Let me clean it up and resubmit it.

miyagawa commented 1 year ago

Well yeah that's orthogonal :) For Plack app/middleware I generally prefer setting these things via callback attributes rather than requiring to subclass it.

davorg commented 1 year ago

Ok. Do you have a good example of how you've used callback attributes elsewhere? I'll crib off that and submit a new PR.

davorg commented 1 year ago

Replaced by https://github.com/plack/Plack/pull/695