[Templates] Re: How to separate between hash and array in data returned from function

Josh Rosenbaum josh@infogears.com
Sun, 11 Feb 2007 10:47:57 -0700


Robin Smidsr=C3=B8d wrote:
> Randal L. Schwartz wrote:
> One a sidenote, is there some way for an object method to know if it is=
=20
> being called from a template (instead of from normal perl code)? Is=20
> there some variable that is set that the function has access to which i=
s=20
> not set otherwise? Or can I use some kind of function (caller) to=20
> inspect the call stack to figure it out? My object contains both read=20
> and write methods, and I want to make sure the write method calls are=20
> not callable from within a template, only from native perl code. Any=20
> pointers would be most helpful.

If you have access to all the code, you could just set a global variable =
right before processing the template and then check for that in your func=
tion.

-- Josh