Skip to content
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

Various issues with automatic adding of $-sign to variable names. #13

Open
lehni opened this issue Jul 25, 2013 · 1 comment
Open

Various issues with automatic adding of $-sign to variable names. #13

lehni opened this issue Jul 25, 2013 · 1 comment

Comments

@lehni
Copy link

lehni commented Jul 25, 2013

I am running into many problems with the automatic variable name substitution, and start to believe it's not a good idea to do this. For example, this code is causing issues:

open = pages->findOpen()
items = open ? open->children()->visible() : false

This gets wrongly translated to:

$__=$pages->findOpen();
$open  = $__
$__=$open ? open->children()->visible() : false;
$items  = $__
 ?>

As you can see, in the second statement, the second occurrence of open does not get replaced.

I have therefore created my own version of jade.php that removes this variable translation, and explicitly use the $-sign in the templates: https://github.com/lehni/jade.php

Don't you think this would make more sense for a PHP based Jade? I am wondering what the official take is on these kind of problems?

@lehni
Copy link
Author

lehni commented Aug 11, 2013

Thinking more about this, I get a feeling you are making a mistake with the trial to automatically translate JavaScript syntax in Jade templates to PHP on the fly. Without a real JavaScript AST Parser this will never work 100% correctly. Also, to me it feels more aligned with the idea of Jade for PHP that it would actually support PHP Syntax inside the Templates, and this aim should be much easier to achieve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant