突出显示php文件中的js代码 [英] Highlighting js-code inside php file
问题描述
我有一个文件script.js.php
.它包含PHP
和JavaScript
代码(js
取决于php
).并且它将作为js文件包含在页面中.
<script type="text/javascript" src="script.js.php"></script>
script.js.php示例
<?php
require_once 'functions.php'
?>
var vars = {
var1: 'value1',
var2: 'value2',
var2: '<?php echo phpFunction(); ?>'
}
有人知道吗,是否可以在不使用script
-tag的情况下在PHP文件中创建PhpStorm
高亮度JavaScript代码?
也许有些伪标签不会影响最终的html/js,但会使PhpStorm高亮代码适当",例如
<!-- <section language="javascript">-->
js goes here
<!-- </section> -->
设置|模板数据语言-查找文件或文件夹,然后将JavaScript
分配给它们(而不是默认HTML).
如果您将内容整理得井井有条,那么您将受益于将所有*.js.php
文件放在单独的子文件夹下-这允许对整个文件夹(以及其中的所有文件)进行一次分配,而不是对单个文件进行多次分配. /p>
I have a file script.js.php
. It contains PHP
and JavaScript
code(the js
depends on the php
). And it is to be included into a page as js-file.
<script type="text/javascript" src="script.js.php"></script>
Example of script.js.php
<?php
require_once 'functions.php'
?>
var vars = {
var1: 'value1',
var2: 'value2',
var2: '<?php echo phpFunction(); ?>'
}
Does anybody know, is it possible to make PhpStorm
higlight JavaScript code within a PHP file without using script
-tag?
Maybe there is some kind of pseudo-tags which wouldn't affect final html/js but make PhpStorm hightlight code "properly", e.g.
<!-- <section language="javascript">-->
js goes here
<!-- </section> -->
Settings | Template Data Languages -- find your file(s) or folder(s) and assign JavaScript
to them (instead of default HTML).
If you keep your stuff well organized, then you will benefit from keeping all *.js.php
files under separate subfolder -- this allows single assignment for a whole folder (and all files inside) instead of multiple assignments for individual files.
这篇关于突出显示php文件中的js代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!