Re: [Templates] setting input checked

2014-12-07 Thread Kiss Gabor (Bitman)
 Yea, I had already tried the single  and it does not work.

Unfortunately there are no arithmetic and bitwise operators in TT.
But in theory the problem can be solved with comparisons only. :-)

Let's assume that flags can be at most 255. Then this logical expression
is equal to flags0x08:

   flags = 248 ||
flags  240  flags = 232 ||
flags  224  flags = 216 ||
flags  208  flags = 200 ||
flags  192  flags = 184 ||
flags  176  flags = 168 ||
flags  160  flags = 152 ||
flags  144  flags = 136 ||
flags  128  flags = 120 ||
flags  112  flags = 104 ||
flags   96  flags =  88 ||
flags   80  flags =  72 ||
flags   64  flags =  56 ||
flags   48  flags =  40 ||
flags   32  flags =  24 ||
flags   16  flags =   8

Gabor

___
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates


Re: [Templates] setting input checked

2014-12-05 Thread Khalid Akram

Try:

  input class=radio type=radio name=recipe_type value=Warmup [% IF 
flags  16 %]checked=1[% END %] /Warmup



From: Bill McCormick wpmccorm...@gmail.commailto:wpmccorm...@gmail.com
Date: Fri, 5 Dec 2014 08:38:35 -0600
To: templates@template-toolkit.orgmailto:templates@template-toolkit.org
Subject: [Templates] setting input checked

[% IF flags  16 %]
  input class=radio type=radio name=recipe_type value=Warmup 
checked=1 /Warmup
[% ELSE %]
  input class=radio type=radio name=recipe_type value=Warmup /Warmup
[% END %]

This e-mail has been scanned for all viruses by Star.___
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates


Re: [Templates] setting input checked

2014-12-05 Thread Khalid Akram
Even better would be:

  input class=radio type=radio name=recipe_type value=Warmup [% IF 
flags  16 %]checked=“checked[% END %] /Warmup


From: Bill McCormick wpmccorm...@gmail.commailto:wpmccorm...@gmail.com
Date: Fri, 5 Dec 2014 08:38:35 -0600
To: templates@template-toolkit.orgmailto:templates@template-toolkit.org
Subject: [Templates] setting input checked

[% IF flags  16 %]
  input class=radio type=radio name=recipe_type value=Warmup 
checked=1 /Warmup
[% ELSE %]
  input class=radio type=radio name=recipe_type value=Warmup /Warmup
[% END %]
This e-mail has been scanned for all viruses by Star.
___ templates mailing list 
templates@template-toolkit.orgmailto:templates@template-toolkit.org 
http://mail.template-toolkit.org/mailman/listinfo/templates

This e-mail has been scanned for all viruses by Star.___
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates


Re: [Templates] setting input checked

2014-12-05 Thread Bill McCormick
okay, so now the bitwise *and *is giving me problems:

input class=radio type=radio name=recipe_type value=Warmup [%
'checked=1' IF 15  16 %]/Warmup

incorrectly (I think) turns into

input class=radio type=radio name=recipe_type value=Warmup
checked=1/Warmup

15 =  
16 = 0001 

last time I checked, 15  16 = 0

Adding parenthesis didn't help either: [% 'checked=1' IF (15  16) %]

Also, is there some way TT can interpret numbers as hexadecimal (e.g. 16 =
0x10)?

Thanks!

On Fri, Dec 5, 2014 at 9:37 AM, Simon Amor si...@leaky.org wrote:

 On 5 Dec 2014, at 14:38, Bill McCormick wpmccorm...@gmail.com wrote:

  I'm trying to find a slick way to make my radio buttons checked. Doing
 something like ...
 
  [% IF flags  16 %]
input class=radio type=radio name=recipe_type value=Warmup
 checked=1 /Warmup
  [% ELSE %]
input class=radio type=radio name=recipe_type value=Warmup
 /Warmup
  [% END %]
 
  ... just seems wrong.
 
  Suggestions?

 This is my preferred way of doing it. It doesn't have as many [% %] tags
 as other options which IIRC makes it a little faster than keep swapping
 between TT and HTML, and it doesn't require the END.

   input class=radio type=radio name=recipe_type value=Warmup[% '
 checked=1' IF flags  16 %] /Warmup

 Regards

 Simon
___
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates


Re: [Templates] setting input checked

2014-12-05 Thread Larry Leszczynski
Hi Bill -

On Fri, Dec 5, 2014, at 09:56 AM, Bill McCormick wrote:
 okay, so now the bitwise *and* is giving me problems:
 
 input class=radio type=radio name=recipe_type value=Warmup [%
 'checked=1' IF 15  16 %]/Warmup

You're doing logical AND, not bitwise AND.  You want 15  16.

Larry

___
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates


Re: [Templates] setting input checked

2014-12-05 Thread Bill McCormick
Yea, I had already tried the single  and it does not work.

On Fri, Dec 5, 2014 at 11:01 AM, Larry Leszczynski lar...@emailplus.org
wrote:

 Actually, that probably only works in a [% PERL %] block...

 On Fri, Dec 5, 2014, at 10:00 AM, Larry Leszczynski wrote:
  Hi Bill -
 
  On Fri, Dec 5, 2014, at 09:56 AM, Bill McCormick wrote:
   okay, so now the bitwise *and* is giving me problems:
  
   input class=radio type=radio name=recipe_type value=Warmup [%
   'checked=1' IF 15  16 %]/Warmup
 
  You're doing logical AND, not bitwise AND.  You want 15  16.
 
  Larry
 
  ___
  templates mailing list
  templates@template-toolkit.org
  http://mail.template-toolkit.org/mailman/listinfo/templates

 ___
 templates mailing list
 templates@template-toolkit.org
 http://mail.template-toolkit.org/mailman/listinfo/templates

___
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates


Re: [Templates] setting input checked

2014-12-05 Thread Bill Moseley
On Fri, Dec 5, 2014 at 6:38 AM, Bill McCormick wpmccorm...@gmail.com
wrote:

 I'm trying to find a slick way to make my radio buttons checked.


For another slick approach take a look at HTML::FillInForm
http://search.cpan.org/dist/HTML-FillInForm/ and the filter
http://search.cpan.org/dist/Template-Plugin-FillInForm/.



 Doing something like ...

 [% IF flags  16 %]
   input class=radio type=radio name=recipe_type value=Warmup
 checked=1 /Warmup
 [% ELSE %]
   input class=radio type=radio name=recipe_type value=Warmup
 /Warmup
 [% END %]

 ... just seems wrong.

 Suggestions?

 Thanks,

 Bill


 ___
 templates mailing list
 templates@template-toolkit.org
 http://mail.template-toolkit.org/mailman/listinfo/templates




-- 
Bill Moseley
mose...@hank.org
___
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates