in reply to Re^2: How to use template toolkit variable in a template toolkit mysql query
in thread How to use template toolkit variable in a template toolkit mysql query

As mentioned by CountZero above, you can’t nest TT that way. This should do what you want but I’m not sure it’s a good idea–

[% FOR row IN rows %] [% query_str = "SELECT * FROM contacts WHERE account_code = ${row.acco +unt_code}" %] [% END %]

Getting this kind of thing out of the templates will be a long run win. If you prefer to do things this way, PHP is probably just as good, if not better, for this style of in-template code. (I prefer Perl.)

Update, as is, that code does nothing really… just sets a variable. So I don’t know it will actually do what you want. :)

  • Comment on Re^3: How to use template toolkit variable in a template toolkit mysql query
  • Download Code

Replies are listed 'Best First'.
Re^4: How to use template toolkit variable in a template toolkit mysql query
by hamidafshar (Novice) on May 05, 2011 at 06:51 UTC
    Absolutely greatful *Your Mother*, *CountZero* and *Chromatic*. Below worked for me:
    [% FOR row IN rows %] [% query_str = "SELECT * FROM contacts WHERE account_code = ${row.acco +unt_code}" %] [% END %]
    I had tried this previously but did not use double quotes - duhhhhhhhhh :-|. Thanks alot you guys.
Re^4: How to use template toolkit variable in a template toolkit mysql query
by hamidafshar (Novice) on May 05, 2011 at 06:54 UTC
    This works