Home Download Buy Blog Forum Support

Closing <script> tags with the close-tag functionality

Closing <script> tags with the close-tag functionality

Postby jamy_za on Tue Jan 31, 2012 1:07 pm

For some reason this doesn't work. Is there any specific reason for this?
Code: Select all
<head>
<script>
var foo = 'bar';

If I press alt + . it will close the <head> tag by inserting </head>. Why doesn't it close the script tag?
jamy_za
 
Posts: 22
Joined: Mon Jul 04, 2011 1:11 pm

Re: Closing <script> tags with the close-tag functionality

Postby joshnh on Wed Feb 01, 2012 5:12 am

This issue seems to be present no matter where the script is (i.e. just before the close of the body element).
Last edited by joshnh on Wed Feb 08, 2012 11:02 am, edited 3 times in total.
joshnh
 
Posts: 14
Joined: Wed Feb 01, 2012 5:11 am
Location: Australia

Re: Closing <script> tags with the close-tag functionality

Postby jamy_za on Wed Feb 01, 2012 6:40 am

I understand why it would do this with <meta /> and <link /> tabs - They don't have closing tags, just like <img />. But <script> does have a closing tag. Is this a bug?
jamy_za
 
Posts: 22
Joined: Mon Jul 04, 2011 1:11 pm

Re: Closing <script> tags with the close-tag functionality

Postby atomi on Wed Feb 01, 2012 10:50 pm

I think this is a problem with HTML.tmLanguage file.

I've wanted to know why, in addition to not being able to close those tags, the matching tag decoration won't work with some tags including script tags.
So, a bump from me. Hopefully someone more knowledgeable chimes in.

EDIT: the tag matching decoration appears to work using meta.tag.blah.html so to fix this issue jps will need to add meta.tag.script.html to the source.js.embedded.html and meta.tag.style.html to the source.css.embedded.html definitions in HTML.tmLanguage

EDIT2: Although this works it will cause the entire block of code within the tags to scope as meta.tag.blah... which will cause problems of it's own. I believe it may be still possible to match source tags without having to scope the entire thing as a meta.tag block

HTH
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Closing <script> tags with the close-tag functionality

Postby jamy_za on Mon Feb 06, 2012 7:31 am

Bump - I think this is a bug and no one is really confirming or denying this.
jamy_za
 
Posts: 22
Joined: Mon Jul 04, 2011 1:11 pm

Re: Closing <script> tags with the close-tag functionality

Postby neilybod on Thu Jan 17, 2013 2:37 pm

It's nearly a whole year since the last post on this... I have the very latest version of ST2 installed and it still won't auto close <SCRIPT> tags...
Can someone post a clear solution on how to fix this please?
It's an annoying niggle in an otherwise awesome editor, and it breaks my workflow :(

Cheers
neilybod
 
Posts: 1
Joined: Thu Jan 17, 2013 2:34 pm

Re: Closing <script> tags with the close-tag functionality

Postby agibsonsw on Thu Jan 17, 2013 4:10 pm

It is quite easy to create a snippet:

Code: Select all
<snippet>
    <content><![CDATA[
<script type="text/javascript">
    $1
</script>$0
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>script</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>text.html.basic</scope>
</snippet>


There is also a Tag plug-in which might work (haven't used it myself).
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Closing <script> tags with the close-tag functionality

Postby agibsonsw on Thu Jan 17, 2013 4:12 pm

..or this version:

Code: Select all
<snippet>
    <content><![CDATA[
<script type="text/javascript">
    $0
</script>
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>script</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>text.html.basic</scope>
</snippet>
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 33 guests