tt vmethod match how to use a var inside

Jochen Schnuerle <[email protected]> Tue, 26 May 2015 16:53:19 +0200
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============6621653442094395058==
Content-Type: multipart/alternative;
 boundary="------------090003090803040801090504"

This is a multi-part message in MIME format.
--------------090003090803040801090504
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

I have following code (i use dancer - so <% is [%):

<% esxiver = "51u2" %>
<% re = '(?x)
                   \b51u2\b
               ';%>
<% esxi = '51,51u2,55' %>

<% IF esxi.match(re) %>
<% esxiver %>
<% END %>

In the example I want to check the var esxi with vmethod .match() if a 
word "51u2" is inside. But instead of write the word fix in the re var, 
I want to use the var esxiver.

I try

<% re = '(?x)
                   \b\$esxiver\b
               ';%>

<% re = '(?x)
                   \b${esxiver}\b
               ';%>

<% re = '(?x)
                   \b'$esxiver'\b
               ';%>

but nothing work.

I try use the re in the match string direct:

<% IF esxi.match('\b${esxiver}\b') %>

Maybe I misunterstand the match method.

Can anyone help me, please ?

Regards

     Jochen



--------------090003090803040801090504
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable

<html><head>
<meta http-equiv=3D"content-type" content=3D"text/html; charset=3DISO-885=
9-15"></head><body
 style=3D"font-family: DIN-Regular;" bgcolor=3D"#FFFFFF" text=3D"#000000"=
>
<div style=3D"font-family: DIN-Regular;"><span style=3D"font-family:=20
DIN-Regular;">Hello,<br><br>I have following code (i use dancer - so=20
&lt;% is [%):<br><br></span><span style=3D"font-family: monospace;">&lt;%=
=20
esxiver =3D "51u2" %&gt;<br>&lt;% re =3D '(?x)</span><br style=3D"font-fa=
mily:
 monospace;"><span style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20
\b51u2\b</span><br style=3D"font-family: monospace;"><span=20
style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
 ';%&gt;</span><br><span=20
style=3D"font-family: monospace;">&lt;% esxi =3D '51,51u2,55' %&gt;</span=
><br
 style=3D"font-family: monospace;"><span style=3D"font-family: monospace;=
">=A0=A0=A0=A0=A0
 </span><br style=3D"font-family: monospace;"><span style=3D"font-family:=
=20
monospace;">&lt;% IF esxi.match(re) %&gt;</span><br style=3D"font-family:=
=20
monospace;"><span style=3D"font-family: monospace;">=A0=A0=A0 &lt;% esxiv=
er=20
%&gt;<br>&lt;% END %&gt;<br style=3D"font-family: monospace;"></span><spa=
n
 style=3D"font-family: DIN-Regular;"><br>In the example I want to check=20
the var esxi with vmethod .match() if a word "51u2" is inside. But=20
instead of write the word fix in the re var, I want to use the var=20
esxiver.<br><br>I try<br><br></span><span><span style=3D"font-family:=20
monospace;">&lt;% re =3D '(?x)</span><br style=3D"font-family: monospace;=
">
<span style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 \b\$esxiver\b</span><br
 style=3D"font-family: monospace;">
<span style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 ';%&gt;</span><br>
<span style=3D"font-family: monospace;"></span> <br></span><span><span=20
style=3D"font-family: monospace;">&lt;% re =3D '(?x)</span><br=20
style=3D"font-family: monospace;">
<span style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 \b${esxiver}\b</span><br
 style=3D"font-family: monospace;">
<span style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 ';%&gt;</span><br>
<span style=3D"font-family: monospace;"></span> <br></span><span><span=20
style=3D"font-family: monospace;">&lt;% re =3D '(?x)</span><br=20
style=3D"font-family: monospace;">
<span style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0 \b'$esxiver'\b</span><br
 style=3D"font-family: monospace;">
<span style=3D"font-family: monospace;">=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0 ';%&gt;</span><br>
<span style=3D"font-family: monospace;"></span> </span><br><span=20
style=3D"font-family: DIN-Regular;">but nothing work.<br><br>I try use th=
e
 re in the match string direct:<br><br></span><span><span=20
style=3D"font-family: monospace;">&lt;% IF esxi.match('\b${esxiver}\b')=20
%&gt;</span> <br><br>Maybe I misunterstand the match method.<br><br></spa=
n><span
 style=3D"font-family: DIN-Regular;"></span><span><meta=20
http-equiv=3D"content-type" content=3D"text/html; charset=3DISO-8859-15">=
<span
 id=3D"result_box" class=3D"short_text" lang=3D"en"><span class=3D"hps"><=
/span><span
 class=3D"hps">Can anyone help me, please ?</span></span><br><br>Regards<=
br><br>=A0=A0=A0
 Jochen<br></span><span style=3D"font-family: DIN-Regular;"><br><br></spa=
n></div>
</body>
</html>

--------------090003090803040801090504--


--===============6621653442094395058==
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

--===============6621653442094395058==--