Template2 icon indicating copy to clipboard operation
Template2 copied to clipboard

[wishlist] Add 'preload' method to store in-memory templates

Open dallaylaen opened this issue 7 years ago • 1 comments

I sometimes wish I could add a precompiled template under some name for the subsequent code to rely on it. My idea of the interface is like follows:

$tt->preload( "name" => \"[% in_memory_template %]" );
# later in the code
$tt->process( "name", \%vars ); 
     # will now work on the provided template
     # instead or looking for it in INCLUDE_PATH

I managed to make a wrapper based on Template::Provider to add such feature to my particular code, but I would love to see it in Template by default.

Or maybe there's a standard way of doing this, but I haven't found it in the docs.

Would love to make a pull request for this if anybody else could need such thing.

dallaylaen avatar Dec 03 '17 21:12 dallaylaen

@dallaylaen do you want to submit a PR so we can look at it?

toddr avatar Oct 05 '18 18:10 toddr