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

Sublime does not enable extension in correct context #6

Closed
calumbrodie opened this issue Feb 17, 2013 · 4 comments
Closed

Sublime does not enable extension in correct context #6

calumbrodie opened this issue Feb 17, 2013 · 4 comments

Comments

@calumbrodie
Copy link
Contributor

I find that I have to manually change the detected syntax to handlebars to get this to work.

I have two scenarios.

  1. Files with the extension 'handlebars.twig' - which are handlebars files written using the twig templating language

  2. (solving this would also solve the above I think) - Within html files where my handlebars template is defined inline, within a script tag with the appropriate type i.e (text/x-handlebars)

<!DOCTYPE html>
  <head>
    <meta charset="utf-8" />
    <title>Ordr: Rstaurant Mnu Systm</title>
  </head>
  <body>

    <script type="text/x-handlebars" data-template-name="application">

     <!-- snippets should be useable inside this scope -->

      <h1>Ordr</h1>
      {{ outlet }}
    </script>

    <script src="js/libs/jquery-1.8.3.min.js"></script>
    <script src="js/libs/handlebars-1.0.0.rc.2.js"></script>
    <script src="js/libs/ember.js"></script>
    <script src="js/libs/ember-data.js"></script>
    <script src="js/app.js"></script>
  </body>
</html>
@calumbrodie
Copy link
Contributor Author

Edit: I see from reading the readme this may be by design: In which case this could be tagged as an enhancement.

@daaain
Copy link
Owner

daaain commented Feb 17, 2013

I haven't heard of Twig yet, but on a quick research it seems that it supports multiple template systems? If that's the case I wouldn't want to hardcode the file type association into the Handlebars package as people who use other templates would be really annoyed that the wrong package is trying to handle their files :) Can you name you file .twig.handlebars?

As for using it inside a HTML script tag, that's a change in the HTML package. It would need to understand that the tag contains Handlebars and load the language definition. I'm not even sure if that package is on Github, if you find it I can try to work with whoever is maintaining it :)

@calumbrodie
Copy link
Contributor Author

I guess the html scoping is handled by sublime natively. The scope within a script tag (embedded) is:

text.html.basic source.js.embedded.html

This seems like a narrow enough scope I think? Where there are conflicts in autocompletion (for example 'if'), between raw js and handlebars, ST2 usually displays both options in a dropdown menu. I think this would be acceptable (what do you reckon?)

edit: Similar issue in jQuery snippets bundle - with relevant commit:
aaronpowell/sublime-jquery-snippets#1

As for twig - Is it possible to only enable if the file extension is 'handlebars.twig' rather than just '.twig' (you are right re: twig supporting multiple template systems). I wouldn't want to change the file extension as .twig is an extension which requires compiling (It's a handlebars file written IN twig rather than the inverse).

Cheers

@calumbrodie
Copy link
Contributor Author

Added a separate PR - will close this.

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

2 participants