[help] how to know "at least one variable was parsed in the template"??
StrongZhu <[email protected]> Mon, 23 Nov 2015 21:37:41 +0800
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <CALArWTw=OZhmbfnTGiPwD01LDidRVA1eLShDwFJf_hiyKG53cA@mail.gmail.com> |
--===============0378457240974439248==
Content-Type: multipart/alternative; boundary=001a1141c126554bb70525355472
--001a1141c126554bb70525355472
Content-Type: text/plain; charset=UTF-8
hi,
I seldom use mail list, so I'm not sure how many person can read this
email.
here is my questions:
I have a hash reference :
hash_ref = {
var_HOST => "1",
var_USER => "abc",
var_PROC => "def",
var_OUTPUT_PATH => "/home/runner/[% var_HOST %]/[% var_USER
%]/[% var_PROC %]/",
}
want to resolve all variables this "hash_ref" first,
then use this hash_ref to parse another template.
I want to :
do
{
for each (var_i in this hash_ref)
{
try to parse 'var_i' with this hash,
if (*NOTHING was parsed*), ignore this var_i
if (failed to parse it) {ignore this var_i for now, maybe it can be
parse successfully later}
else , e.g. for 'var_OUTPUT_PATH', parse it, overwrite this var_i
}
} while (at least one var was parsed in this do-while loop)
so, must know *whether the "parse" procedure at least parsed one
variable. or not*
is there any way do achieve this ??
thanks.
Sincerely
--001a1141c126554bb70525355472
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">hi,<div>=C2=A0 I seldom use mail list, so I'm not sure=
how many person can read this email.</div><div><br></div><div>=C2=A0 here =
is my questions:</div><div><br></div><div>=C2=A0 I have a hash reference :<=
/div><div>hash_ref =3D {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 var_HOST=C2=A0=3D> "1",</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 var_USER=C2=A0=3D> "abc",</div><div>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var_PROC=C2=A0=3D> "def",</=
div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 var_OUTPUT_PATH=C2=A0=3D=
> "/home/runner/[% var_HOST %]/[% var_USER %]/[% var_PROC %]/"=
,</div><div>=C2=A0}</div><div><br></div><div>=C2=A0 want to resolve all var=
iables this "hash_ref" first,=C2=A0</div><div>=C2=A0 then use thi=
s hash_ref to parse another template.</div><div><br></div><div>=C2=A0 I wan=
t to :</div><div><br></div><div>do</div><div>{</div><div>=C2=A0 for each (v=
ar_i in this hash_ref)</div><div>=C2=A0 {</div><div>=C2=A0 =C2=A0 try to pa=
rse 'var_i' with this hash,</div><div>=C2=A0 =C2=A0 if (<b>NOTHING =
was parsed</b>), =C2=A0ignore this var_i<br></div><div>=C2=A0 =C2=A0 if (fa=
iled to parse it) {ignore this var_i for now, maybe it can be parse success=
fully later}<br></div><div>=C2=A0 =C2=A0 else , e.g. for 'var_OUTPUT_PA=
TH', parse it, overwrite this var_i</div><div><br></div><div>=C2=A0 }</=
div><div>} while (at least one var was parsed in this do-while loop)</div><=
div><br></div><div><br></div><div>=C2=A0 so, must know <u><b>whether the &q=
uot;parse" procedure at least parsed one variable. or not</b></u></div=
><div><br></div><div>=C2=A0 is there any way do achieve this ??</div><div><=
br></div><div>=C2=A0 thanks.</div><div><br></div><div>=C2=A0=C2=A0</div><di=
v><br></div><div><br><div><br></div><div>Sincerely</div></div></div>
--001a1141c126554bb70525355472--
--===============0378457240974439248==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates
--===============0378457240974439248==--