Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Splitting long text for Template (updated)

by LanX (Saint)
on Feb 07, 2021 at 23:19 UTC ( [id://11128038]=note: print w/replies, xml ) Need Help??


in reply to Splitting long text for Template

In my experience is the MVC approach more an ideal° than a bulletproof method.

BUT ... in this case I'd say it belongs into the View.

One rational for MVCs is the possibility to delegate responsibility to domain experts in your team (or to be at least capable to easily scale your team up if necessary)

So ask yourself: Whose responsibility is it?

IMHO it'll be the decision of the designer of the View how long the visible text is and how it's presented.

It's not the domain of the programmer (Controller) nor the DB-Admin (Model)

Unfortunately I lack expertise with Template::Toolkit on how best to achieve this ... it has it's own mini language.

But I suppose there is more then one way and the Monastery is full of experts. :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

°) Shaky Metaphor: A good Christian might attempt to follow the example of Jesus, but not many are ready to die at the cross.

UPDATE

> The other way I came up with was to use a callback from the template to the Perl function that splits the text. Again, this seems to tie the logic and display together.

I'd keep such Perl code inside a separate file/module named like view_helper.pl with an extra namespace like package View::Helper;

See it as an extension of your template framework in the responsibility of your designer. He might delegate change requests to the programmer, if he can't handle Perl, but it's his call.

Replies are listed 'Best First'.
Re^2: Splitting long text for Template (updated)
by Bod (Parson) on Feb 08, 2021 at 00:16 UTC
    So ask yourself: Whose responsibility is it?

    Thank you - that's the sort of great question that, when asked, can bring so much clarity. That has helped a lot.

    Implementation may prove a challenge but clarity is always a good start.

      > Implementation may prove a challenge but clarity is always a good start.

      I know, for the time being your team is small and you are playing all roles by yourself.

      But imagine having a split personality disorder, where on certain weekdays you are a "Mr. Designer" without hard programming skills.

      This cartoon reflects my experience quite well

      Your "Dr. Programmer" should try to offer your Mr. Designer a custom Perl-function to be embedded

      ($visible,$hidden) = divide_by_words($text,100)

      which is maintained in a dedicated view-helper module.

      One day you might realize that web-design is not your forte and you want to hire someone creative who is good with colors, fonts, user experience, pink unicorns and so on.

      No need to require Perl or Regex skills then, your Perl programmers will maintain the central view-helper-module for the designer.

      And one day the programmer will realize that split / +/ is not a good idea and fix it at one central place instead of dozens of templates.

      And the designer can decide to change the "100" to another number depending on output media and page.

      One anecdote: (I told this before ...)

      My first payed Perl job was in a (former) start up which created little interactive ads embedded in thousands of partnering web-sites.

      The team was divided into programmers, designers, dev-ops, some DBAs and (pseudo) management.

      To my horror I realized that JS was considered the responsibility of the designers who couldn't really code ... (well with one exception).

      That worked reasonably well as long as they only used standard features from frameworks like MooTools, but imagine the C&P disaster when they googled for more complex logic.

      I tried to argue that it'll be wiser if someone from the Perl department provided the JS coding. But that's how I learned how management "works".

      Disclaimer:

      I'm a bad designer and have the highest respect for good ones.

      If you leave web-design to programmers you'll end up in sites like this one.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        But imagine having a split personality disorder

        Some days, I really do not have to imagine very hard 😜

        One day you might realize that web-design is not your forte and you want to hire someone creative who is good with colors, fonts, user experience, pink unicorns and so on.

        I already realise that!!!
        I have a graphic designer on the team who selects colour palettes, fonts and general design guides.

        I am also very seriously considering employing a junior developer to do all the web design work...it is unlikely to be this year but it is part of the decision to start to refactor the Perl code to split logic from display using Template. It will make life easier either way and will make it possible to have someone else take over much of the front end implementation.

        If you leave web-design to programmers you'll end up in sites like this one

        You already know I agree with you there...
        So that is why I am trying to do something about itbefore it is too late.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-20 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found