string compare working in controller but not in view

32 views
Skip to first unread message

v.

unread,
Feb 1, 2019, 9:00:44 AM2/1/19
to Fat-Free Framework
I have a weird problem.
Consider this code inside a controller:
        $r="<";
       
if($r=="<"){
            echo
1;
       
}
       
else{
            echo
0;
       
}
        $this
->f3->set('r',$r);
        $this
->f3->set('view','show.htm');

output clearly is 1.
The view however :
<check if='{{ @r }} == "<" '>
<true>
true {{ @r }}
</true>
<false>
 false {{ @r }}
</false>
</check>
returns "false <"!

the cache seem to translate to
<?php if ($r  == '<'): ?>

true
<?= $r.PHP_EOL ?>

<?php else: ?>
 false
<?= $r.PHP_EOL ?>

<?php endif; ?>

This does not make sense.

If I change "<" to an alphanumerical value it does work.
Why is this?

Richard Goldstein

unread,
Feb 1, 2019, 9:09:59 AM2/1/19
to v. via Fat-Free Framework

Weird – It that the actual translation of the template?

 

I cant explain your output, but I suggest changing the line in your template to:

<check if=”{{ @r == "<" }}”>

 

(If you copy/paste fix the quotes – my email client is using directional quotes)

--
-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.
To view this discussion on the web visit https://groups.google.com/d/msgid/f3-framework/3a18dd39-18b0-4b05-8c18-4cfa1744676c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

v.

unread,
Feb 1, 2019, 9:38:54 AM2/1/19
to Fat-Free Framework


Weird – It that the actual translation of the template?

it is

 

I cant explain your output, but I suggest changing the line in your template to:

<check if=”{{ @r == "<" }}”>

I can't use double quotes twice, but I did try to change the check quotes to single and the comparison quotes to double and also putting the comparison between the {{ }}
All I havae tried returns a false

Richard Goldstein

unread,
Feb 1, 2019, 10:55:50 AM2/1/19
to v. via Fat-Free Framework

Can you swap the quotes so the the if=”” has the double quotes? I’m wondering about the parsing of the template – though your template output looks right. If the code cut/pasted from your editor?

 

From: "v. via Fat-Free Framework" <f3-framework+APn2wQfsu8MCcWHUosn...@googlegroups.com>


Date: Friday, February 1, 2019 at 4:38 AM
To: Fat-Free Framework <f3-fra...@googlegroups.com>

--

-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.

Richard Goldstein

unread,
Feb 1, 2019, 11:09:08 AM2/1/19
to v. via Fat-Free Framework

I was able to reproduce this - @r is being converted to &lt; - by the template renderer I’m sure – If test clause was output Id understand but its not  so I don’t think it should to this but it is.

 

Try outputting {{ htmlspecialchars(@r) }} or view page source and you’ll see it

 

 

From: "v. via Fat-Free Framework" <f3-framework+APn2wQfsu8MCcWHUosn...@googlegroups.com>


Date: Friday, February 1, 2019 at 4:38 AM
To: Fat-Free Framework <f3-fra...@googlegroups.com>

--

-- You've received this message because you are subscribed to the Google Groups group. To post to this group, send an email to f3-fra...@googlegroups.com. To unsubscribe from this group, send an email to f3-framework...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/f3-framework?hl=en
---
You received this message because you are subscribed to the Google Groups "Fat-Free Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to f3-framework...@googlegroups.com.
To post to this group, send email to f3-fra...@googlegroups.com.
Visit this group at https://groups.google.com/group/f3-framework.

v.

unread,
Feb 3, 2019, 9:06:44 AM2/3/19
to Fat-Free Framework
You're right doc, the output is getting converted.

I have also tried all sorts of variations with <check if=' {{ @r | raw }} == "<" '> without success.

<check if='{{ @r }} == "&lt;"'> does work though and allows me to create a workaround although I would like to understand why the original comparison does not work

Reply all
Reply to author
Forward
0 new messages