List Info

Thread: Feature req/idea: storing variables in cached templates




Feature req/idea: storing variables in cached templates
user name
2007-07-17 05:02:12
Hi Smarty team, just wanted to start by saying that you've
all built a 
great piece of software. It's fantastic.

I had a little conundrum which is not really killing me but
it leaves 
just a niggling little want.

I was wondering how breaking it would be to be able to load
variables 
from a precompiled/cached smarty template and use these
variables in 
one's application code, before displaying that cached
template (using a 
func like get_cached_template_vars() 
<http://smarty.php.net/manual/en/api.get.template.va
rs.php> ) . I was 
looking at those 2 lines of metadata in the cached template
files, which 
gave me the idea. I figure that, for recovering very small
procedural 
booleans, it beats the hell out of building your own data
caching store 
when smarty's is already so well done.

My specific application of this is have
dynamically-generated HTTP 
headers (containing a seed-value from the time the template
was 
compiled) sent before my cached HTML templates, which can
only be done 
from the application code and not in any portion of the
smarty toolchain 
(from all the ways I've tried to test). Maybe I'm wrong
there, but I 
ain't bright enough to prove it. I don't see the smarty
class putting 
any uninvited carriage-returns (and other weird text)
between the 
header()s it does and the echo() of the compiled template,
but I imagine 
PHP does some protection and special lexing of header()
calls vs. echo() 
(like when I try to put the raw HTTP header text in the
template) - 
enough difference to make the web server change from the
HTTP track to 
the HTML track and thus making my headers go out as content
instead of 
preceding it.

If my idea ain't ludicrous, I venture there should also be
an attribute 
to smarty->assign() that would be specified by the
programmer to 
indicate each variable that he would like stored with cached
 template, 
rather than smarty assuming it should be so (in case of
large arrays and 
such)?

Unless I'm missing something, it doesn't seem like
outputfilters are 
applied to display()s of cached templates - and even if they
did, the 
lazy dev is still obligated to find a place to
store/retrieve his old 
variables from.


Thanks,
Joey

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )