Twig-Eclipse-Plugin icon indicating copy to clipboard operation
Twig-Eclipse-Plugin copied to clipboard

File association

Open anod opened this issue 13 years ago • 10 comments

We are using in project *.html files, I associated them with twig editor, but document still not recognized as Twig template

I noticed that there is a check for extenion can cause this problem src / org / eclipse / twig / ui / editor / TwigStructuredEditor.java

if ("twig".equals(resource.getFullPath().getFileExtension())) { TwigSourceParser.editFile.set(resource); super.doSetInput(input); } else { super.doSetInput(input); }

anod avatar Jun 14 '11 07:06 anod

does this work for php code, ie. if you open a *.html file with the PHP Editor - do you get PHP syntax highlighting?

I've added the html extension to the TwigStructuredEditor, but somehow it's still not using the TwigEditor. Same happens for PHP syntax if i open an *.html file with the php editor.

pulse00 avatar Jun 14 '11 08:06 pulse00

Yes, same behavior

anod avatar Jun 14 '11 15:06 anod

This is how you can make the Twig editor recognizy any file extension you wish as twig content-type:

  1. Open Eclipse Preferences -> General -> Content Types
  2. Under Text -> PHP Content Type -> Twig Template add the file association you need ( in your case *.html)
  3. Close any currently open editors
  4. Reopen the .html file and you should get twig support.

pulse00 avatar Jun 23 '11 11:06 pulse00

I'm atempting the same, but it won't use the twig syntax highlighting.

I set *.html for twig template under content types. I also added *.twig to file association and set twig editor as default.

I use the 'open with -> twig editor' method, still it won't work! Using Eclipse Juno and your nightly build

The same problem exists for PHP editor or smarty templates I tried some other stuff, created files with .twiggy and .smarty extension and it works fine. Then I tried creating a .lol extension template and if php, smarty and twig need to compete over it then twig always 'wins'.

There seems to be something wrong with eclipse ignoring the File Association or the custom choice with 'open with' and just going for whatever it feels should be the default

rubensayshi avatar Oct 10 '12 16:10 rubensayshi

Okay I've been trying different stuff and the behavory is really weird.

I also installed http://eclipse.kacprzak.org/ since the django editor is almost the same as twig and it's working properly but nonetheless the behavory stays odd!

I created an imaginary file extension .ben Added that extension to the contenttypes PHP, Twig, Smarty and Django

Now I try to open the file with 'open with' and I get the following results: Django Editor -> opens in Django Editor Twig Editor -> opens in Twig Editor Smarty Editor -> opens in Twig Editor PHP Editor -> opens in Twig Editor

The default is set to Smarty Editor at this point so it's completely ignoring that ...

I don't get it, I just know it's messed up and if I can't even set it right for .ben then I'm definitely not going to get it right for .html ...

rubensayshi avatar Oct 11 '12 16:10 rubensayshi

tested with clean install of indigo and juno, both are showing the same problem :(

rubensayshi avatar Oct 16 '12 10:10 rubensayshi

Manually adding the TwigNature does the trick

rubensayshi avatar Oct 16 '12 10:10 rubensayshi

what do you mean with TwigNature ?

pierregermain avatar Jul 25 '14 07:07 pierregermain

trying to add *.html extension to work with twig highlighting. but it isn't working, even if open with twig editor.

added here "Under Text -> PHP Content Type -> Twig Template"

any advice?

stylek avatar Aug 29 '14 08:08 stylek

Hello, I solved this with nature: rigth click on project: Configure-> Convert to Twig Project.

Regards,

vrubiella avatar Nov 10 '14 11:11 vrubiella