samholmes / EJS.tmLanguage

An EJS syntax definition specifically for sublime text
47 stars 28 forks source link

Shouldn't it be <% %> ? #1

Closed videoMonkey closed 11 years ago

videoMonkey commented 12 years ago

I should first thank you for taking the initiative to create an EJS package for sublime, thanks, but I have to ask why did you choose <? ?> when the ejs page clearly states that <% %> is the default tag form. I would prefer it to be like that.

samholmes commented 12 years ago

The <, > and ? keys are closer to each other, and it is a personal preference of mine. I made this package out of necessity because other EJS tmLanguage files broke under sublime's default set of bundles. I would very much like to support % and ? variations, but I'm unsure how this would work in a tmLanguage file. Any suggestions would greatly be appreciated, I would very much like to maintain this syntax definition for the entire sublime text community.

One idea would be to allow an either-or approach. That is, the syntax definition would recognize <? and ?> or <% and %>, but this would mean event <? and %> or <% and ?> would be defined as valid EJS.

videoMonkey commented 12 years ago

It would be nice to do an either or approach, or to be able to allow the user to define what their tags look like, because some will probably want {{ }} tags. At any rate, I want to build a keyboard shortcut that works that it doesn't really matter what the key distance is to type the tags.

samholmes commented 12 years ago

I'm not sure how this might work. Is it even possible to dynamically change the tmLanguage file based on what open and closing tags the user defines?

videoMonkey commented 12 years ago

I am not entirely certain how to do it, but I think a sublime text environment variable could be set and then accessed by the snippet. I don't have time to work on it this week. I am a bit of a sublime text noob, but I'll try and take a look next week.

samholmes commented 12 years ago

Likewise, I'm a noob to ST and I'm super busy this week; it's the 4th of july, so yeah. I had some talks on the IRC channel, but nothing really figured out yet. I'll keep this issue updated with whatever information I find.

metamatt commented 11 years ago

+1 for this request.

rodrigok commented 11 years ago

+1 for this request.

rafaelks commented 11 years ago

+1 for this request.

otondin commented 11 years ago

+1 for this request.

p2 commented 11 years ago

+1

saurori commented 11 years ago

This was annoying me as well. I ended up uninstalling this EJS package and setting all .ejs files to open with HTML (Rails). You can do this by opening an .ejs file, go to View > Syntax > Open all with current extension as...

Looks much better, but may not be perfect.

stilenx commented 11 years ago

For those of you wanting to use this convenient .tmLanguage with the default tags, I think making the change for yourself isn't too bad (seems to work for me). Change lines 579: <string>&lt;\?=?-?</string> to: <string>&lt;%=?-?</string> and 589: <string>\?&gt;</string> to: <string>%&gt;</string> Now, as to having that be some kind of setting, lost on how to do that one.

samholmes commented 11 years ago

Thanks, stilenx. I should have posted these instructions; I'll put them in the readme for now.

As for making it a setting, I'm lost on this too. I'm not a python developer and I am having trouble understanding the environment that sublime's plugins run in. If anyone has any suggestion and experience with sublime text plugin API, please let me know what is possible. I tried asking around on forums and IRC, but had no luck.

stilenx commented 11 years ago

If I find anything I'll let you know. Also not a python developer, so no promises. Also see my edit, I accidentally copy pasted the actual strings from the line wrong (or github ate them).

samholmes commented 11 years ago

Use a to start code and another to end it;like thiswould be comelike this`. You can edit the comment with this in mind.

stilenx commented 11 years ago

Thanks

videoMonkey commented 11 years ago

I don't have any idea how to make this a preference, but here is a repository you can install that uses % rather than ?

https://github.com/videoMonkey/EJS.tmLanguage

samholmes commented 11 years ago

I fixed this issue by adding two options in the command palette. Please read the new README on the github repo for reference on how to switch between the two different syntaxes.