Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
In my quest of Refactoring webcode to use templates, I have hit an issue which I can solve in a couple of ways. But...I am trying to keep the logic separate from the display and whichever way I look at, I am struggling to maintain that separation. On an HTML page I have a block of text pulled from a database. The length of the text is not known until runtime. If the text is too long, it is split into a visible and a hidden section with the display attribute toggled by a bit of Javascript. The code that does the shortening and formatting of the text will become a function in a module but it currently is a subroutine in the script that outputs all the HTML.
If I use the same code with a Template, I am going to be passing partly formatted text to the process method. This does not entirely separate the logic from the display as part of the display is created in the Perl code. 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. Is there an elegant solution that I am overlooking to what must be quite a common problem? In reply to Splitting long text for Template by Bod
|
|