在 Eclipse 中突出显示 .tpl 语法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4079399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:16:53  来源:igfitidea点击:

Highlight .tpl syntax in Eclipse

eclipse

提问by Webnet

I've been googling and can't find a solution for this. I'm trying to setup .tpl files to use either HTML syntax highlighting or PHP syntax highlighting. Has anyone does this, or do you know how?

我一直在谷歌搜索,找不到解决方案。我正在尝试设置 .tpl 文件以使用 HTML 语法突出显示或 PHP 语法突出显示。有没有人这样做过,或者你知道怎么做?

Thanks

谢谢

回答by sreimer

  • Go to Window -> Preferences-
  • Then General -> Editors -> File Associations-
  • Add the PHP Editor to the *.tpl file type. You may have to create the *.tpl type if it doesn't already exist.
  • 转到窗口-> 首选项-
  • 然后 General -> Editors -> File Associations-
  • 将 PHP 编辑器添加到 *.tpl 文件类型。如果 *.tpl 类型尚不存在,您可能必须创建它。

You may also have to set the content type for your tpl files in Content Types also under the General settings. Scroll down to PHP Source File and make sure *.tpl exists there as well.

您可能还需要在“内容类型”中的“常规”设置下为 tpl 文件设置内容类型。向下滚动到 PHP 源文件并确保 *.tpl 也存在于那里。

Then you need to restart eclipse to make it work.

然后你需要重新启动 eclipse 以使其工作。

回答by svlzx

  • Go to Window -> Preferences -> General -> Content Types
  • Select Text -> CSS, click Add, write *.tpl and save.
  • Do the step two for Text -> HTML, Javascript and PHP.
  • 转到窗口 -> 首选项 -> 常规 -> 内容类型
  • 选择 Text -> CSS,点击 Add,写入 *.tpl 并保存。
  • 对 Text -> HTML、Javascript 和 PHP 执行第二步。

回答by Mizbah Ahsan

I took that from this link. You can get that form there or I give their content below if the anyhow that link doesn't work. It works for me nicely.

我是从这个链接中获取的。如果无论如何该链接不起作用,您可以在那里获取该表格,或者我在下面提供其内容。它对我很有效。

steps how to install SmartyPDT 0.9.1

如何安装 SmartyPDT 0.9.1 的步骤

Be sure that the .TPL files are not associated with any content type (file type). In Eclipse,

确保 .TPL 文件不与任何内容类型(文件类型)相关联。在日食中,

  1. Be sure that the .TPL files are not associated with any content type (file type). In Eclipse,
  2. Go to Help-> Install New Software
    • At the Work With section click on the Add... button. Give the new "Site" a name and set the location with http://smartypdt.googlecode.com/svn/trunk/org.eclipse.php.smarty.updatesite/, then click OK. Go back to the Install New Software window and select the newly added "site". If the "Group items by category" check-box is checked, uncheck it. Now you should be able to see 1 item in the software list named "Smarty Feature"
  3. Select the Smarty Feature, click Next> and from here afterwards it shouldn't be a problem.
    • If you are prompted that this is an unsigned package, just ignore the warning and install it anyway.
  4. After the installation completes, restart Eclipse and it should be working.
  5. Define a default PHP executable of type 'Zend Debugger' (only if you install vanilla Eclipse PDT):
    • In Eclipse go to Window->Preferences->PHP->PHP Executables Click on the Add button. Enter a name for that executable definition, for example "PHP localhost", complete the 2 fields which ask you for the PHP executable path (the PHP binary CLI executable) and php.ini path. Be sure that the PHP debugger is the Zend Debugger.
  1. 确保 .TPL 文件不与任何内容类型(文件类型)相关联。在日食中,
  2. 转到帮助-> 安装新软件
    • 在“使用”部分单击“添加...”按钮。为新的“站点”命名并设置位置http://smartypdt.googlecode.com/svn/trunk/org.eclipse.php.smarty.updatesite/,然后单击确定。返回“安装新软件”窗口并选择新添加的“站点”。如果选中“按类别分组项目”复选框,请取消选中它。现在您应该能够在名为“Smarty Feature”的软件列表中看到一项
  3. 选择 Smarty Feature,单击 Next>,然后从这里开始应该没有问题。
    • 如果系统提示您这是一个未签名的包,请忽略警告并安装它。
  4. 安装完成后,重新启动 Eclipse,它应该可以工作了。
  5. 定义“Zend Debugger”类型的默认 PHP 可执行文件(仅当您安装 vanilla Eclipse PDT 时):
    • 在 Eclipse 中,转到 Window->Preferences->PHP->PHP Executables 单击 Add 按钮。输入该可执行文件定义的名称,例如“PHP localhost”,完成要求您提供 PHP 可执行文件路径(PHP 二进制 CLI 可执行文件)和 php.ini 路径的 2 个字段。确保 PHP 调试器是 Zend Debugger。

回答by Heri

Installing smarty on eclipse kepler fails

在 eclipse kepler 上安装 smarty 失败

(see Install SmartyPDT 0.0.9.1 in Eclipse Kepler).

(请参阅在 Eclipse Kepler 中安装 SmartyPDT 0.0.9.1)。

The recommendation there is to use the PHP Development Tools (PDT) from former eclipse juno version. But in contrary to the recommendation I did not DELETE the mentioned features folder but I just uninstalled the plugins from eclipse itself (Help/About/InstallationDetails):

建议使用以前的 eclipse juno 版本中的 PHP 开发工具 (PDT)。但与建议相反,我没有删除提到的功能文件夹,但我只是从 eclipse 本身卸载了插件(帮助/关于/安装详细信息):

  • Uninstall all PDT packages
  • Restart eclipse
  • Then follow the instructions in above answer to install the PDT packages from Juno version and then the smarty package.
  • 卸载所有 PDT 软件包
  • 重启日食
  • 然后按照上述答案中的说明安装 Juno 版本的 PDT 包,然后安装 smarty 包。

All these Installations worked without error.

所有这些安装都没有错误。

But unfortunatly the *.tpl files are still not syntax highlighted. What to do more?

但不幸的是 *.tpl 文件仍然没有语法突出显示。还要做什么?

回答by molder

Our *.tpl file extension is not associated with the HTML editor in Eclipse by default.

默认情况下,我们的 *.tpl 文件扩展名与 Eclipse 中的 HTML 编辑器无关。

  1. Open Eclipse's preferences.
  2. Expand General from the tree on the left and select Content Types.
  3. Expand Text on the right and select HTML. Click the Add... button below, enter *.tpl and click the OK button.
  4. General -> Editors -> File Associations
  5. Click Add..., enter *.tpl, and click OK.
  6. Select HTML Editor from the Associated editors: section below and click the Default button to the right.
  1. 打开 Eclipse 的首选项。
  2. 从左侧的树中展开 General 并选择 Content Types。
  3. 展开右侧的文本并选择 HTML。单击下面的添加...按钮,输入 *.tpl 并单击确定按钮。
  4. 常规 -> 编辑器 -> 文件关联
  5. 单击添加...,输入 *.tpl,然后单击确定。
  6. 从下面的 Associated editor: 部分中选择 HTML Editor,然后单击右侧的 Default 按钮。