pulse00 / Twig-Eclipse-Plugin

Eclipse plugin for the twig templating language.
twig.dubture.com
MIT License
107 stars 24 forks source link

File association #4

Open anod opened 13 years ago

anod commented 13 years ago

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); }

pulse00 commented 13 years ago

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.

anod commented 13 years ago

Yes, same behavior

pulse00 commented 13 years ago

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.
rubensayshi commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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

rubensayshi commented 12 years ago

Manually adding the TwigNature does the trick

pierregermain commented 10 years ago

what do you mean with TwigNature ?

stylek commented 10 years ago

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?

vrubiella commented 10 years ago

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

Regards,