Highlight .tpl syntax in Eclipse

2020-02-26 05:59发布

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?

Thanks

标签: eclipse
5条回答
爷的心禁止访问
2楼-- · 2020-02-26 06:35
  • 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.

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.

Then you need to restart eclipse to make it work.

查看更多
家丑人穷心不美
3楼-- · 2020-02-26 06:38

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

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

  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.
查看更多
▲ chillily
4楼-- · 2020-02-26 06:41

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

  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.
查看更多
我欲成王,谁敢阻挡
5楼-- · 2020-02-26 06:54

Installing smarty on eclipse kepler fails

(see Install SmartyPDT 0.0.9.1 in Eclipse Kepler).

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):

  • 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.

All these Installations worked without error.

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

查看更多
Explosion°爆炸
6楼-- · 2020-02-26 06:59
  • 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.
查看更多
登录 后发表回答