in reply to Perl Template::Toolkit combining variables?

I don't understand your requirements, both the why and the what is a mystery to me. For example: Why do you have to use this data structure? If the data structure is not suitable for the templating system you can just generate a second temporary suitable data structure out of the data, call the template and throw the temporary data away.

But even with your actual data it seems you just need a nested loop to access the values:

[% FOREACH TimeData IN ReturnValues %] [% FOREACH Rd IN TimeData %] [% TimeData.Rd %] [% END %] [% END %]

Disclaimer: I'm not an TT expert

Replies are listed 'Best First'.
Re^2: Perl Template::Toolkit combining variables?
by Frederic_S (Novice) on Jan 05, 2011 at 13:44 UTC
    Hey Jethro, what I want or better need to do is a concatenation of two variables in the template. Usually you concatenate two variables with a "." as in:

    $Variable1."-".$Variable2;
    Output:

    Value1-Value2

    This doesn't work in the template.

    Depending on what utilization ratio a programmer has, a certain value needs to be output in the template. This is why I need to make the template variable dynamic.

    The first part of the variable is:

    [% TimeData.RemainingTimeNEW- OR [% TimeData.RemainingTimeASSIGNED-
    Now I need to concatenate the second part of the variable.

    [% TimeData.RemainingTimeNEW-UtilRatioPercent %]
    I tried the following solutions but with no luck:

    [% TimeData.RemainingTimeNEW-_UtilRatioPercent %] [% TimeData.RemainingTimeNEW-$UtilRatioPercent %] [% TimeData.RemainingTimeNEW-${UtilRatioPercent} %] [% TimeData.RemainingTimeNEW-.UtilRatioPercent %]
    The variable should be read out as:

    TimeData.RemainingTimeNEW-75

    Where the 75 is variable

    Hope this sheds some light on what I want.

    Regards,

    Fred