in reply to Best practices: Generating HTML content

Have you considered using a template solution to separate your HTML/JavaScript etc from your perl code?

  • Comment on Re: Best practices: Generating HTML content

Replies are listed 'Best First'.
Re^2: Best practices: Generating HTML content
by Anonymous Monk on Dec 23, 2017 at 02:01 UTC

    I have moved to templates for larger chunks of code. This particular line (and a couple of other smaller snippets of js) is part of a module in a larger project and it didn’t seem like a good use of resources to pull in another module for three lines of code. It seemed like overkill.

      Does the larger project involve "larger chunks of code", of the sort you've moved to templates for? Probably.

      Does the larget project, therefore, use templates? Hopefully.

      If so, then using the same templating system in this module as in the larger project isn't pulling in anything new, it's just using what will already be loaded as a part of the overall project.

      And, if not, I wouldn't let that stop me from maintaining a clean separation of concerns by using templates in the module anyhow. On the contrary, I'd start with templates in the module, since that appears to be where you're currently writing new code, then expand from there until all of the HTML content in the entire project is produced using templates instead of coming from mixed HTML and Perl frankencode.