0

I've *.js.php-Files and would like to

  1. highlight the syntax as JavaScript
  2. supress warnings caused by lines like

    <?php if ($cond == true):?>alert("true!");<?php endif;?>
    

Does anybody know, how to tell Eclipse, it should handle *.js.php files not as *.php but as *.js?

Please don't talk about the pros and cons of mixing PHP and JS. It's just about the Eclipse issue.

Thanks in advance!

2
  • Why don't you just make it a .js and set in your .htaccess that it should be parsed as PHP? Commented May 22, 2013 at 14:27
  • @Johan Good advice but unfortunately not possible in this project. The files are already there and I'm the poor one who has to extend the code. Commented May 22, 2013 at 14:40

2 Answers 2

1

I'm sorry, but this answer isn't a real answer:

You can add user defined file associations in

  • Window->Preferences
  • Options->Editors->File Associations

The problem is you can't add *.php and *.js.php there at the same time, because *.php includes *.js.php...

You can always add the JavaScript editor to the "*.php" to make it appear in the "Open With" menu, when you right click a file in the filelist.

For your second problem: I think the only way to fix this is by extends the JavaScript plugin. For example making a comment. But that's a more complex topic.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply. Unfortunately I already know and tried the way you suggest. It doesn't work as I need.
1

I've had a similar problem in a different IDE,

<?php $this->headScript()->captureStart(); ?>

$(document).ready(function(){ ... });

<?php $this->headScript()->captureStart(); ?>

Obviously, no IDE will correctly highlight that javascript since there is no indication it should be javascript... so I did:

<?php $this->headScript()->captureStart(); ?>
// <script>

$(document).ready(function(){ ... });

<?php $this->headScript()->captureStart(); ?>

This tells the IDE it's javascript, and while it's included in the actual source, it's commented so won't break anything

Hope this helps

1 Comment

Unfortunately, it's not the final solution but it highlights the code as JS - great idea, thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.