Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to collapse javascript functions with <%= in Visual Studio 2012

In Visual Studio 2012 when editing markup/aspx, you can apparently collapse javascript functions as long as they don't contain special server tags such as the shortcut for Response.Write <%=.

Examples:

Can collapse:

function foo() {
    var x = 0;
}

Can not collapse:

function bar() {
    var x = $find("<%= txtWhatever.ClientID %>");
}

I've noticed as soon as you add the opening tag <%=, the collapse option (-) to the left of the word function disappears, so I know that's the problem.

It appears to break the collapsing of the entire function regardless of size/contents.

I've tried the Web Essentials plugin as well as the Advanced Javascript outlining plugin, but neither seems to work for functions with this particular content either.

Is there any way to make functions containing these types of tags collapsible?

Thanks-

like image 837
kman Avatar asked Jan 14 '13 20:01

kman


1 Answers

Only a workaround:

Wrap each function in its own script tag.

A bug has apparently been opened with the JS team about this.

like image 176
Andrew Hagner Avatar answered Oct 19 '22 06:10

Andrew Hagner