Home Download Buy Blog Forum Support

When in Rails - why does if <tab> generate a php snippet?

When in Rails - why does if <tab> generate a php snippet?

Postby saracen on Mon Aug 08, 2011 8:07 pm

When I'm working on a .html.erb file in rails and I type:
Code: Select all
if <tab>

I get a php snippet as follows:
Code: Select all
<?php if (condition): ?>
 
<?php endif ?>


Any ideas why? I'm new to Sublime - awesome so far just trying to get the hang of it.

Also, on a related note, what is the snippet for generating an open and close erb tag
Code: Select all
<%= %>

Either with or without the "=" sign?

And is there an easy to view all the snippets along with their tab completion keys other than going into the filesystem and opening up each .snippet file?
saracen
 
Posts: 1
Joined: Mon Aug 08, 2011 8:03 pm

Re: When in Rails - why does if <tab> generate a php snippet?

Postby chrisgaunt on Sun Sep 04, 2011 12:04 am

Same problem here. In a file named example.html.erb using "HTML (Rails)" when I type "if <tab>" it returns a PHP snippet when it should be Ruby.
I'd normally just remove the PHP snippets but I have to maintain a legacy PHP app too.

Any help appreciated :)
chrisgaunt
 
Posts: 2
Joined: Tue Mar 22, 2011 12:36 pm
Location: Japan

Re: When in Rails - why does if <tab> generate a php snippet?

Postby thetristan on Mon Sep 19, 2011 12:22 am

Not sure about the first one, but I created a snippet that works well for <%= %> and <% %> tags.

Code: Select all
<snippet>
   <content><![CDATA[<%${1:=} $2 %>]]></content>
   <tabTrigger>&lt;</tabTrigger>
</snippet>


If I don't need the tag to output, I can just backspace the '=' after the first tab and then tab again to the middle; otherwise, if I do need the output, I just double-tab and I'm all set.

Hope this helps.
thetristan
 
Posts: 1
Joined: Mon Sep 19, 2011 12:18 am

Re: When in Rails - why does if <tab> generate a php snippet?

Postby shx on Tue Jun 26, 2012 3:03 pm

I'm getting PHP snippets showing in a html.erb file as well.

Thanks thetristan for the snippet. It was on my list of things to fix in my ST2 setup before I buy a license.

Using dev build 2207 and the context ST2 is using is "HTML (Rails)" so I don't know why PHP snippets are showing.

I'm assuming I could just delete my php snippets but I would prefer to not have to do that.
shx
 
Posts: 1
Joined: Tue Jun 26, 2012 2:40 pm

Re: When in Rails - why does if <tab> generate a php snippet?

Postby tkab on Mon Jul 23, 2012 10:22 am

the problem is the scope[1] of the PHP snippets. For them it is 'text.html - source'. An .html.erb file has the scope 'text.html.ruby', this is included in the PHP snippets' scope.

I would consider this a bug, since I find it not useful to litter all text.html.* scopes with PHP snippets and suggest to limit their scope to text.html.php.

[1] to find out the scope use ScopeHunter (available via Package Control)
tkab
 
Posts: 2
Joined: Mon Jul 23, 2012 10:09 am

Re: When in Rails - why does if <tab> generate a php snippet?

Postby JamesChevalier on Tue Nov 13, 2012 8:39 pm

tkab wrote:the problem is the scope[1] of the PHP snippets. For them it is 'text.html - source'. An .html.erb file has the scope 'text.html.ruby', this is included in the PHP snippets' scope.

I would consider this a bug, since I find it not useful to litter all text.html.* scopes with PHP snippets and suggest to limit their scope to text.html.php.

[1] to find out the scope use ScopeHunter (available via Package Control)


This is definitely the issue.

Adding a new Ruby/Rails 'else' snippet isn't very helpful, because then ST2 just prompts for which snippet to use. It seems like moving/removing the PHP folder (or just the offending snippets), then creating custom Ruby/Rails snippets is the only workaround until this bug is fixed.

Edit:
Another possible workaround might be to search out all instances of "<scope>text.html" in the ~/Library/Application Support/Sublime Text 2/Packages/PHP folder and replace them with "<scope>text.php".
JamesChevalier
 
Posts: 1
Joined: Tue Nov 13, 2012 8:28 pm

Re: When in Rails - why does if <tab> generate a php snippet?

Postby lperry65 on Mon Nov 26, 2012 5:02 pm

Has there been any movement on this issue? will it be fixed in a future release?
lperry65
 
Posts: 8
Joined: Mon Nov 26, 2012 4:29 pm


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 19 guests