As I promised way back on January 18, here's a patch to the 2.13 docs for the 'caller' and 'callers' fields I added to 'component'.
For reference, here's the post with the code patch: http://template-toolkit.org/pipermail/templates/2004-January/005581.html Enjoy, Dave /L\_/E\_/A\_/R\_/N\_/T\_/E\_/A\_/C\_/H\_/L\_/E\_/A\_/R\_/N\ Dave Cash Power to the People! Frolicking in Fields of Garlic Right On-Line! [EMAIL PROTECTED] Dig it all. diff -ru lib/Template/Manual/Variables.pod.orig lib/Template/Manual/Variables.pod ##### BEGIN PATCH ##### --- lib/Template/Manual/Variables.pod.orig Fri Jan 30 12:37:50 2004 +++ lib/Template/Manual/Variables.pod Wed Mar 17 10:00:51 2004 @@ -767,6 +767,36 @@ [% template.name %] # foo [% component.name %] # footer +Additionally, the 'component' variable has two special fields: +'caller' and 'callers'. 'caller' contains the name of the template +that called the current template (or undef if the values of +'template' and 'component' are the same). 'callers' contains a +ref to a list of all the templates that have been called on the +road to calling the current component template (like a call stack), +with the outer-most template first. + +Here's an example: + +'outer.tt2': + + [% component.name %] # 'outer.tt2' + [% component.caller %] # undef + [% component.callers %] # undef + [% PROCESS 'middle.tt2' %] + +'middle.tt2': + + [% component.name %] # 'middle.tt2' + [% component.caller %] # 'outer.tt2' + [% component.callers %] # [ 'outer.tt2' ] + [% PROCESS 'inner.tt2' %] + +'inner.tt2': + + [% component.name %] # 'inner.tt2' + [% component.caller %] # 'middle.tt2' + [% component.callers %] # [ 'outer.tt2', 'middle.tt2' ] + =item loop Within a FOREACH loop, the 'loop' variable references the Template::Iterator ###### END PATCH ###### diff -ru docs/src/Manual/Variables.html.orig docs/src/Manual/Variables.html ##### BEGIN PATCH ##### --- docs/src/Manual/Variables.html.orig Fri Jan 30 12:37:18 2004 +++ docs/src/Manual/Variables.html Wed Mar 17 09:56:45 2004 @@ -769,6 +769,39 @@ <pre> [% tt_start_tag %] template.name [% tt_end_tag %] # foo [% tt_start_tag %] component.name [% tt_end_tag %] # footer</pre> +<p> +Additionally, the 'component' variable has two special fields: +'caller' and 'callers'. 'caller' contains the name of the template +that called the current template (or undef if the values of +'template' and 'component' are the same). 'callers' contains a +ref to a list of all the templates that have been called on the +road to calling the current component template (like a call stack), +with the outer-most template first. +</p> +<p> +Here's an example: +</p> +<p> +'outer.tt2': +</p> +<pre> [% tt_start_tag %] component.name [% tt_end_tag %] # 'outer.tt2' + [% tt_start_tag %] component.caller [% tt_end_tag %] # undef + [% tt_start_tag %] component.callers [% tt_end_tag %] # undef + [% tt_start_tag %] PROCESS 'middle.tt2' [% tt_end_tag %]</pre> +<p> +'middle.tt2': +</p> +<pre> [% tt_start_tag %] component.name [% tt_end_tag %] # 'middle.tt2' + [% tt_start_tag %] component.caller [% tt_end_tag %] # 'outer.tt2' + [% tt_start_tag %] component.callers [% tt_end_tag %] # [ 'outer.tt2' ] + [% tt_start_tag %] PROCESS 'inner.tt2' [% tt_end_tag %]</pre> +<p> +'inner.tt2': +</p> +<pre> [% tt_start_tag %] component.name [% tt_end_tag %] # 'inner.tt2' + [% tt_start_tag %] component.caller [% tt_end_tag %] # 'middle.tt2' + [% tt_start_tag %] component.callers [% tt_end_tag %] # [ 'outer.tt2', 'middle.tt2' ]</pre> + <li><b>loop</b><br> <p> Within a FOREACH loop, the 'loop' variable references the Template::Iterator ###### END PATCH ###### _______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
