Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File association #4

Open
anod opened this issue Jun 14, 2011 · 10 comments
Open

File association #4

anod opened this issue Jun 14, 2011 · 10 comments
Milestone

Comments

@anod
Copy link

anod commented Jun 14, 2011

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
Copy link
Owner

pulse00 commented Jun 14, 2011

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
Copy link
Author

anod commented Jun 14, 2011

Yes, same behavior

@pulse00
Copy link
Owner

pulse00 commented Jun 23, 2011

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 pulse00 closed this as completed Jun 23, 2011
@rubensayshi
Copy link

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

@pulse00 pulse00 reopened this Oct 10, 2012
@rubensayshi
Copy link

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
Copy link

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

@rubensayshi
Copy link

Manually adding the TwigNature does the trick

@pierregermain
Copy link

what do you mean with TwigNature ?

@stylek
Copy link

stylek commented Aug 29, 2014

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
Copy link

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

Regards,

@zulus zulus added this to the 2.0.0 milestone Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants