daaain / Handlebars

Fullest Handlebars.js templating support for Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from: https://packagecontrol.io/packages/Handlebars.
MIT License
301 stars 48 forks source link

add more recognized file extensions, patterns for YAML front matter and code comments #16

Closed jonschlinkert closed 11 years ago

jonschlinkert commented 11 years ago

add more file extensions to be more accommodating to others add patterns for YAML front matter

jonschlinkert commented 11 years ago

I think this resolves https://github.com/daaain/Handlebars/issues/10

Arkkimaagi commented 11 years ago

Came here looking for fixes on these issues, found Jon from assemble already working on these. Funny how small the world is.

+1 on anything that fixes with the frontmatter further.

@jonschlinkert, does this improve how sublime text handles code inside frontmatter also, like changing the indent from tab to space inside this area?

jonschlinkert commented 11 years ago

@Arkkimaagi It does improve how YAML front matter is highlighted, but I'm not sure about what effect is has on tabs versus spaces.

Arkkimaagi commented 11 years ago

Just a stupid question, how does this get updated to package manager and when? Thanks :)

Edit: Nevermind, apparently automatically :D

daaain commented 11 years ago

Yeah, it's automatic but sometimes there's a bit of delay.

As a side note, @jonschlinkert just realised that you've been editing the plist XML directly so I ported your changes back to JSON. It's much nicer to work with, installing AAAPackageDev and using that to work with it is highly recommended! :)

jonschlinkert commented 11 years ago

@daaain sorry about that, I actually do work with the JSON when I do something from scratch, I guess I just didn't think about it since the changes were pretty simple

jonschlinkert commented 11 years ago

@daaain is there a reason you only merged part of the pull request? You didn't merge in the only parts I actually cared about in the request lol. The YAML front matter and extensions.

I just looked at the JSON file and it looks like you're formatting it manually, so I probably won't mess with that. I have fixes for the DOCTYPE issue and javascript inside script tags, but I don't have lot of time for this.

daaain commented 11 years ago

Strange, I merged the whole lot, just used the big green button here in the Github UI :)

I did regenerate the plist to make spaces and tabs consistent, but it should be exactly the same content as your version: https://github.com/daaain/Handlebars/commit/b11979e741f334e7abcee36d459b02baed8a3f51#diff-1

So after updating via Package Manager it doesn't work? Does it show the right date and time?

jonschlinkert commented 11 years ago

Yeah, it is strange, I actually pulled down your repo again and just opened it up - like 10 minutes ago. But since you just made that comment I looked at the file and it is indeed updated with the code from my pull request. What's strange is that I deleted the repo locally after I made the pull request, then I pulled it down again and it had only the code for the comments merged in... weird.

Anyway, accept my apologies for being presumptuous.

jonschlinkert commented 11 years ago

Btw, to clarify, when I looked at the file here on the repo it was updated, but it was still in the state I described locally... anyway, strange. I tried to see if I did something stupid (which is quite common) but I'm not sure what I happened.

To fix the issue I mentioned with javascript in script tags and doctype, just add the following directly below the #partial_and_var include in the patterns array :

{ "include": "#text.html.basic" }

It's not idiomatic, but it works. I've been using this for the last day, and I've edited at least 75 mixed content files and I haven't seen an issue.

daaain commented 11 years ago

No worries, might be something going on with Github's backend?

I tried to include the bit you just mentioned, but I'm getting errors on the ST2 console: Unknown include #text.html.basic, are there some dependencies?

But in general I guess a much better approach would be to somehow include another HTML package like HTML5 instead of reinventing the HTML related bits, but I'm not quite sure how to do it in a nice way.

daaain commented 11 years ago

Wait, I guess you meant "include": "text.html.basic" without the #, right?

daaain commented 11 years ago

This actually seems to solve a lot of problems by doing exactly what I was wishing for above, and just by quickly messing around it also seems that the whole #html_tags and its dependencies can be removed! If you have a bit of time can you please try if the branch html-refactor works for you?

jonschlinkert commented 11 years ago

I guess you meant "include": "text.html.basic" without the #, right?

Yes! I'm sorry if that caused you some frustration. I'm glad you got it straightened out, I'll have to take a look at the html-refactor branch this evening or tomorrow. Thanks!

jonschlinkert commented 11 years ago

btw, it sounds like you've had a chance to do some testing locally, has it been giving you any problems?

daaain commented 11 years ago

From what I've seen so far it looks all right, except for templates inside script tags which are not given the right Handlebars context any more :(

jonschlinkert commented 11 years ago

except for templates inside script tags which are not given the right Handlebars context any more :(

IMO that's not even worth trying to fix. It's such a small trade-off compared to the advantages.

jonschlinkert commented 11 years ago

Any progress on getting text.html.basic included? it fixes I think 4 of the 5 issues you have. I've had to keep manually adding it, so if you are concerned about templates in script tags I guess I can just fork it.

daaain commented 11 years ago

I haven't got around yet to figure out the script tag bit, will take another look on Monday. So the rest seems fine to you? I wish there was a good way of creating a functional test suite!

daaain commented 11 years ago

Finally got around to spend a day getting a bit deeper, it seems to work perfectly now :)

I've also included some test case files, so in case you spot something let me know what to add there or just create a pull request and I can take a look.

jonschlinkert commented 11 years ago

great thanks!