Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.13

Request #1974 IF conditions like x=="a"
Submitted: 2004-07-24 19:33 UTC
From: aemadrid at gmail dot com Assigned:
Status: Verified Package: HTML_Template_Flexy
PHP Version: 4.3.7 OS: Linux RH 2.1AS
Roadmaps: (Not assigned)    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2004-09-13 16:56 UTC
Package:
Bug Type:
Summary:
From: aemadrid at gmail dot com
New email:
PHP Version: Package Version: OS:

 

 [2004-07-24 19:33 UTC] aemadrid at gmail dot com
Description: ------------ Would you consider adding support for IF conditions like x=="a"? It could have a syntax like flexy:if="x:#a#"? It is kind of cumbersome to create switch case conditions with only simple true/false conditions like flexy:if="x" or flexy:if="!x" as it stands right now.

Comments

 [2004-08-07 02:25 UTC] alan_k
good idea.. I'm not sure when it would be done.. If someone wants to send a patch, it would be faster..
 [2004-09-11 13:55 UTC] bat at flurf dot net
I figured out a way to do this. Suppose you want something like this (remembering that string literals are enclosed in #hashes#: {if:user=#root#}<a href="...">Admin</a>{end:} This syntax isn't supported. My solution is to add to your object a function like this: function equal($x,$y) { return $x == $y; } and then, instead of the above (illegal) syntax, use this: {if:equal(user,#root#)}...<a href="...">Admin</a>{end:} Works perfectly!
 [2004-09-13 16:56 UTC] aemadrid at gmail dot com
Good thinking! Simple and effective. Thanks for the tip.
 [2004-09-15 06:07 UTC] bat at flurf dot net
This trick is pretty powerful, actually. You want to have your template include other templates? Put something like this in the template html: {includeTemplate(#froggy.html#)} ... and something like this in your object definition: function includeTemplate($filename) { $content = new HTML_Template_Flexy(/* options... */); $content->compile($filename); return $content->bufferedOutputObject($this); } It works flawlessly!