Re: [htmltmpl] Template math
Brought to you by:
samtregar
From: Brian M. <bm...@pa...> - 2002-11-13 18:46:40
|
Yep, I do similar things every day with HTML::Template::Expr. Like most perl and perl related solutions, you could do this one of several ways... You might try using successive <TMPL_IF EXPR="score < x"> statements (which is rather lengthy, so I won't write it out), or you could try the following: (For the sake of simplicity, I'll use the 10 star option, just so you can get the idea) <img src="/images/<TMPL_VAR EXPR="int(score / 100)">-stars.gif"> The problem with this is that int() isn't going to be too terribly accurate. Read the part of the H-T-Expr docs regarding custom functions and you should be able to handle the inaccuracy by using a rounding function instead of int(). Brian McCain PageMasters Internet Group ----- Original Message ----- From: "Dave Desrochers" <da...@vo...> To: "Bill Moseley" <mo...@ha...>; <htm...@li...> Sent: Wednesday, November 13, 2002 7:06 AM Subject: Re: [htmltmpl] Template math | Although I haven't used it myself, you should be able to use | HTML::Template::Expr to perform this with some nested "<TMPL_IF EXPR=>" | statements. | | | | At 06:54 AM 11/13/2002 -0800, Bill Moseley wrote: | | >I'm using HTML::Template to display results from a search engine. Each | >result has a rank or score that is an integer <= 1000 and is available as | >a template variable. | > | >Now let's say we want to display stars or a percentage instead of the rank | >number. For example, six stars would be a score of 1000. | > | >I feel like those are display issues -- the web designer might want to use | >10 stars, or a bar graph. So is there a way to accomplish this in the | >template directly based on the rank, instead of requiring a change to the | >code that creates the template variables? | > | >Thanks, | > | >-- | >Bill Moseley mo...@ha... | > | > | > | >------------------------------------------------------- | >This sf.net email is sponsored by: Are you worried about | >your web server security? Click here for a FREE Thawte | >Apache SSL Guide and answer your Apache SSL security | >needs: http://www.gothawte.com/rd523.html | >_______________________________________________ | >Html-template-users mailing list | >Htm...@li... | >https://lists.sourceforge.net/lists/listinfo/html-template-users | | ---------- | David J. Desrochers | Information Systems Manager | CoreComm | 2875 Eyde Parkway | East Lansing, MI 48826 | | | | | ------------------------------------------------------- | This sf.net email is sponsored by: Are you worried about | your web server security? Click here for a FREE Thawte | Apache SSL Guide and answer your Apache SSL security | needs: http://www.gothawte.com/rd523.html | _______________________________________________ | Html-template-users mailing list | Htm...@li... | https://lists.sourceforge.net/lists/listinfo/html-template-users | |