dongshushi5579 2011-11-01 17:13
浏览 24

Intellij在同一文件中突出显示javascript和php的语法

I have a JavaScript file that needs to have some PHP tags in it. Something like this:

var chart = {
  init: function() {
    ...
    drawChart(this.data);
    ...
  },

  data: <?php echo $this->data ?>
}

The output is obviously a pure JavaScript file and functionally this is working fine. However, IntelliJ isn't correctly highlighting the code. If I name the file with a .js extension, it starts showing errors as soon as it runs across a PHP tag. If I name the file with a .php extension, it doesn't show any syntax errors, but doesn't highlight any of the JavaScript, only the PHP.

I know it's capable of doing this because I can name the file with a .php extension and surround all the code with <script> tags and everything highlights correctly. Unfortunately that would break my application.

Does anyone know of a way I can get highlighting to work for both languages without script tags?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题