Nvu progress 20050519
By glazou on Thursday 19 May 2005, 10:40 - Nvu - Permalink
PHP nerds, be happy:
Update: the pref is now gone, and the whole thing is now automatic, following this suggestion. If an attribute's value contain the chunk <?php
, the escaping is not done. I know it should be more intelligent than that, and escape the value's parts outside of the PHP code but that's all I can offer for now. Please don't ask for the <? ... ?>
form, I am not going to implement it, it's deprecated.
Comments
Yes yes yes yes yes yes yes :D
I'm pretty sure that all my php templates are going to work with Nvu, without the "search & replace" hell.
I can't wait to test that one!
Mucho congrats from a happy PHP nerd ;-)
Daniel, instead of having a preference for this, how hard would it be to have a PHP mode, automatically invoked when editing files with a .php extension which did the right thing? It doesn't really matter to me as I don't use PHP but it seems like it would be better UI to just 'do the right thing'.
...or if Nvu could automatically detect tags that look like php, <?php, <? and such?
noname: interesting idea...
<?=$variable?> are what i think most people put in attributes i think...
It's a little better than <?php print($variable); ?> even if it is "deprecated".
But i understand that in a new soft you try to educate users.
BTW Daniel, if NVu can detect <?php, couldn't it also detect <% %> tags?
Well, for most PHP template engines, we use "{variable}" as attribute value... the template engine parses its TEXT, not its dom content.
So I think the best would be to keep the "Don't encode special characters in URLs" pref, or even better a "Don't encode special characters in ATTRIBUTES", so "{variable}" doesn't get serialized as "%7Bvariable7D" (which, of course, wouldn't work in a php template engine).
PS : for common PHP template engines like Smarty or FastTemplates, it is possible to use pure HTML templates, without any embedded php code, just using {vars} or {include('show.php')} in content or attributes.
Templates are parsed in TEXT mode, so the encoding of special chars like {[]} really matters... and for now it is not possible to choose attributes' char encoding.
If Nvu could have a pref to keep all attributes values un-escaped, it would be the best PHP template editor for most common template engines.
I hope it works with: <%= test() %> for us ruby on rails guys!
Good work!
I tend to agree with some of the others that have posted regarding leaving the preference setting intact. Modifying the preference to include any HTML attributes could be useful as well. For example, in many cases where I have a rather long dynamically-generated page, I put some PHP in <A NAME="<?=$section_name?>" /> to let users skip down to different spots in the page.
I suppose the issue would be if the developer decides to throw in some extra double quotes..
I tend to agree with some of the others that have posted regarding leaving the preference setting intact. Modifying the preference to include any HTML attributes could be useful as well. For example, in many cases where I have a rather long dynamically-generated page, I put some PHP in <A NAME="<?=$section_name?>" /> to let users skip down to different spots in the page.
I suppose the issue would be if the developer decides to throw in some extra double quotes..
If I'm really no fan of these kind of potage, congrats for that fix, it will please a lot of people who like soup (don't shoot me :D)
Still, one real-world thing I regularly come accross is the abominous:
<input type="checkbox" <?php echo ($value ? 'checked="checked"': null)?> />
or the like.
I know we are no longer speaking of attribute values here.
Still if there's a chance to extend your fix to such cases, I think you'll cover 99% of all the horrible code we see nowadays ;)
Regards
- O.G.
Anonymous Coward: urrrrggghhh, no that one is TOTALLY impossible in Nvu.
Daniel Glazman:
Nevermind, I hate it and I always give the whip to my fellows when they come to me with such horrors :D
Offtopic:
Any news about that one?
forum.nvudev.org/viewtopi...
Can't wait for 1.0
Best regards