cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

\Phalcon\Tag::linkTo through Volt renders erroneous HTML

Open dimhoLt opened this issue 13 years ago • 9 comments

Hello!

First, I want to thank you guys for an amazing framework that has given me back my inspiration for coding in PHP. You guys rock!

Was troubleshooting a strangely behaving javascript when at last I found that the cause was an un-closed <a>-tag above it. I didn't consider this possibility since I hadn't built that markup myself.

sorter.volt

<div class="sorter">
    <h3 class="label">Sort by:</h3>

    <span class="highlighter">&nbsp;</span>

    {% set sorters = [
        'Latest',
        'Shortest',
        'Longest'
       ]
    %}
    {% for index, sorter in sorters %}
        {{ link_to('#', sorter, 'class': 'option' ~ (index is 0 ? ' active' : ''), 'data-sort-by': friendly_title(sorter)) }}
    {% endfor %}

</div>

Result after first-time page load:

Note that the first link - 'latest' - is missing a less-than sign on the close tag

           <div class="sorter">
    <h3 class="label">Sort by:</h3>

    <span class="highlighter">&nbsp;</span>

                <a href="/#" class="option active" data-sort-by="latest">Latest/a>            <a href="/#" class="option" data-sort-by="shortest">Shortest</a>            <a href="/#" class="option" data-sort-by="longest">Longest</a>        
</div>

Result after following page loads:

Note that yet another character - the slash - has also disappeared

<div class="sorter">
    <h3 class="label">Sort by:</h3>

    <span class="highlighter">&nbsp;</span>

                <a href="/#" class="option active" data-sort-by="latest">Latesta>            <a href="/#" class="option" data-sort-by="shortest">Shortest</a>            <a href="/#" class="option" data-sort-by="longest">Longest</a>        
</div>

I haven't found any information regarding this, or any cause. At first, I thought it was NetBeans acting strangely (I'm using NB 7.3), but since the link is generated through the Tag-class, that can't be it.

Please tell me if I can help more with the troubleshooting.

Best regards, dimhoLt

dimhoLt avatar Apr 18 '13 00:04 dimhoLt

Hey dimhoLt, what version of PHP are you using, and what version of Phalcon, and OS?

ghost avatar Apr 18 '13 00:04 ghost

Hello!

This is my dev machine with the following specs:

PHP: PHP 5.4.11 (through Zend Server) Phalcon: 1.0.0b2 OS: Mac OSX 10.8.3

dimhoLt avatar Apr 18 '13 00:04 dimhoLt

Anyway to update to 1.0.1 that is available in master branch?

ghost avatar Apr 18 '13 01:04 ghost

Sure! I'll try it right away.


Edit: Updated now, running Phalcon 1.0.1, same problem. It seems like the first time the PHP-file is generated by Volt, the less-than sign goes missing, and all consecutive page requests of the generated file removes the slash as well. If I wait for a while, the slash returns for one page load, then it vanishes again.

dimhoLt avatar Apr 18 '13 01:04 dimhoLt

This seems strange, I've tested the same code on my machine and it generates the following:

<?php echo $this->getContent(); ?>

<h1>Congratulations!</h1>

<p>You're now flying with Phalcon.</p>

<div class="sorter">
    <h3 class="label">Sort by:</h3>

    <span class="highlighter">&nbsp;</span>

    <?php $sorters = array('Latest', 'Shortest', 'Longest'); ?>
    <?php foreach ($sorters as $index => $sorter) { ?>
        <?php echo Phalcon\Tag::linkTo(array('#', $sorter, 'class' => 'option' . (($index == 0 ? ' active' : '')), 'data-sort-by' => Phalcon\Tag::friendlyTitle($sorter))); ?>
    <?php } ?>

</div>

ghost avatar Apr 22 '13 14:04 ghost

Hmm, maybe the problem is not in Phalcon, but in my PHP / Apache / Zend configuration... I'll do some additional testing on these things and get back to you with my findings.

dimhoLt avatar Apr 22 '13 14:04 dimhoLt

Thanks, could you try copy-pasting the generated code by Volt, (the php code) in the volt template, to check if it's a problem related to the Phalcon\Tag component?

ghost avatar Apr 22 '13 14:04 ghost

Absolutely =) I'll do that as soon as I get home from work.

dimhoLt avatar Apr 22 '13 14:04 dimhoLt

Hello again. It seems the problem has magically solved itself, don't really know how it happened since I haven't been working on the project or changed my environment (the problem had been around for months, since I introduced the component in question), so right now, I can't reproduce it.

I'll get back to you with the results of aforementioned troubleshooting if the problem occurs again. Until then, many thanks for looking into the issue.

dimhoLt avatar Apr 24 '13 21:04 dimhoLt