-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Volt Replacing Single Quote with Double Quote #16019
Comments
Also double quotes now interpret PHP variables. I had to put (external) JSON data to an attribute, but one of my variable name was the part of a JSON property name. Maybe single quotes would be safer in Volt. // oversimplified example
{% set today = date('Y-m-d') %}
<div{{ ' data-json=\"{_$today: 1}\"' }}"></div>
// translated to (which obviously leaked the value of $today, and caused parsing error in JS):
<div data-json="<?= "{_$today: 1}" ?>"></div> |
... one more thing: |
Resolved in #16024 |
Personally having this completely destroy volt templates generated HTML with PHP parser errors I'd think "status: medium" seems a little shy of how bad this actually was especially during RC phase. Cheers, |
Actually it will not. The latest commit reverted everything to what it was before, therefore existing templates will work as expected. The only difference is that if one is using the {{ tag.title("\t", "\n\n") }} <?= $this->tag->title("\t", "\n\n"); > The reason it was set to medium was because of that - it does not break backwards compatibility. |
Our experience differs from that:
The code generated was definitely wrong:
Now I don't know if that's a different issue but we reverted to RC2 and there it's fine. I guess we will see after RC4 or the release is out. |
I recently updated to the latest RC3 and the original single quote issue has been resolved in RC3 now. |
I meant to add that I think in your case, the issue is a PHP parsing error and not a Phalcon bug. PHP can't handle quotes inside of quotes. The PHP parsing is ending with your second double quote. I would change the code to the following (note single quote around 'readonly'):
I believe that will solve your error. |
Err, but all versions of Phalcon up until RC2 did it in a way that it didn't break the code Phalcon generated: |
@fichtner Let me run a test on this. Maybe something was missed. What is the exact volt code if you don't mind? |
Thank you bud. I will get that test going today and report back. |
@fichtner I run the whole template using RC3 and this is what I got <tr id="row_<?= $id ?>" <?php if ((empty($advanced) ? (false) : ($advanced)) == 'true') { ?> data-advanced="true"<?php } ?>>
<td>
<div class="control-label" id="control_label_<?= $id ?>">
<?php if ((empty($help) ? (false) : ($help))) { ?>
<a id="help_for_<?= $id ?>" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a>
<?php } elseif ((empty($help) ? (false) : ($help)) == false) { ?>
<i class="fa fa-info-circle text-muted"></i>
<?php } ?>
<b><?= $label ?></b>
</div>
</td>
<td>
<?php if ($type == 'text') { ?>
<input type="text"
class="form-control <?= (empty($style) ? ('') : ($style)) ?>"
size="<?= (empty($size) ? ('50') : ($size)) ?>"
id="<?= $id ?>"
<?= ((empty($readonly) ? (false) : ($readonly)) ? 'readonly="readonly"' : '') ?>
<?php if ((empty($hint) ? (false) : ($hint))) { ?>placeholder="<?= $hint ?>"<?php } ?>
>
<?php } elseif ($type == 'hidden') { ?>
<input type="hidden" id="<?= $id ?>" class="<?= (empty($style) ? ('') : ($style)) ?>" >
<?php } elseif ($type == 'checkbox') { ?>
<input type="checkbox" class="<?= (empty($style) ? ('') : ($style)) ?>" id="<?= $id ?>">
<?php } elseif ($this->isIncluded($type, ['select_multiple', 'dropdown'])) { ?>
<select <?php if ($type == 'select_multiple') { ?>multiple="multiple"<?php } ?>
<?php if ((empty($size) ? (false) : ($size))) { ?>data-size="<?= $size ?>"<?php } ?>
id="<?= $id ?>"
class="<?= (empty($style) ? ('selectpicker') : ($style)) ?>"
<?php if ((empty($hint) ? (false) : ($hint))) { ?>data-hint="<?= $hint ?>"<?php } ?>
data-width="<?= (empty($width) ? ('334px') : ($width)) ?>"
data-allownew="<?= (empty($allownew) ? ('false') : ($allownew)) ?>"
data-sortable="<?= (empty($sortable) ? ('false') : ($sortable)) ?>"
data-live-search="true"
<?php if ((empty($separator) ? (false) : ($separator))) { ?>data-separator="<?= $separator ?>"<?php } ?>
></select><?php if ((empty($style) ? ('selectpicker') : ($style)) != 'tokenize') { ?><br /><?php } ?>
<a href="#" class="text-danger" id="clear-options_<?= $id ?>"><i class="fa fa-times-circle"></i> <small><?= $lang->_('Clear All') ?></small></a>
<?php if ((empty($style) ? ('selectpicker') : ($style)) == 'tokenize') { ?> <a href="#" class="text-danger" id="copy-options_<?= $id ?>"><i class="fa fa-copy"></i> <small><?= $lang->_('Copy') ?></small></a>
<a href="#" class="text-danger" id="paste-options_<?= $id ?>" style="display:none"><i class="fa fa-paste"></i> <small><?= $lang->_('Paste') ?></small></a>
<?php } ?>
<?php } elseif ($type == 'password') { ?>
<input type="password" autocomplete="new-password" class="form-control <?= (empty($style) ? ('') : ($style)) ?>" size="<?= (empty($size) ? ('50') : ($size)) ?>" id="<?= $id ?>" <?= ((empty($readonly) ? (false) : ($readonly)) ? 'readonly="readonly"' : '') ?> >
<?php } elseif ($type == 'textbox') { ?>
<textarea class="<?= (empty($style) ? ('') : ($style)) ?>" rows="<?= (empty($height) ? ('5') : ($height)) ?>" id="<?= $id ?>" <?= ((empty($readonly) ? (false) : ($readonly)) ? 'readonly="readonly"' : '') ?>></textarea>
<?php } elseif ($type == 'info') { ?>
<span class="<?= (empty($style) ? ('') : ($style)) ?>" id="<?= $id ?>"></span>
<?php } ?>
<?php if ((empty($help) ? (false) : ($help))) { ?>
<div class="hidden" data-for="help_for_<?= $id ?>">
<small><?= $help ?></small>
</div>
<?php } ?>
</td>
<td>
<span class="help-block" id="help_block_<?= $id ?>"></span>
</td>
</tr> |
Note the line:
I also wrote a test just for that and it passes just fine here: https://github.com/niden/cphalcon/commit/99925b1ce1da9e3f7138bb006149a0dbf1ab3d28 |
I am going to release a new RC today, so if you don't mind let's check this again with the new version so as not to have issues like this. Changing and refactoring volt templates is not something I want developers to do. |
@niden I'll give it a try as soon as the next RC is out. Thanks! |
@niden Likewise, I'll also update and test when the new RC release is available! |
@niden RC4 looks fine from here. Will continue to monitor for the rest of the week. Thanks for your help! |
Thank you gents. I am closing this one for now but please report back if anything is not as it should be. |
Just wanted to close the loop by adding that my initial error has indeed been resolved in 5.0.0RC4. As always, I will open a new ticket if anything else pops up. |
I am setting the following variables in my VOLT file:
This was working as expected in RC2 and produced:
But now in RC3 I'm getting the following:
The code is replacing the single quotes with double quotes which is breaking everything.
The original behavior needs to be returned.
Details
Additional context
Nothing more is required.
The text was updated successfully, but these errors were encountered: