in reply to Passing array of references to Template
I find that putting breakdowns of complex data structures into a template can be problematic, because now we have functionally-related logic in two different places and in two different formats. I like to address this sort of issue using closures: code-references, passed to the template, which resolve to subs which are defined (as variables) within the routine that is calling the template. When the template refers to the closure, that code is executed ... and, “where is ‘that code?’ Why, it’s right here.”
Speaking very broadly here, I want there to be a very clear separation of concerns between the template – which I only want to be concerned with presentation – and the procedural logic of the calling program. I want to very studiously avoid having one be dependent upon the other.