I’m primarily a Javascript developer, and I’ve increasingly embraced function composition as a means of keeping things SOLID, which means a great volume of my code takes the form of arguments passed to functions (often highly nested) – is there a way I can get Sublime Text (3) to recognise parentheses as foldable?
As an example of problem code, here’s a common structure I use for defining DOM templates (using Mithril):
module.exports = {
controller : function(){
this.toggleMenu = function(){
model.menuExpanded( !model.menuExpanded() );
}
},
view : function( ctrl ){
return m( 'div', {
className : 'page' + ( model.menuExpanded() ? ' menuExpanded' : '' )
},
m( 'button.btn.btn-large', {
onclick : ctrl.toggleMenu
},
m( 'span.glyphicon.glyphicon-th-list',
m( 'span.text-hide', 'Toggle menu display' )
)
] )
] );
}
};
The majority of the code above is unfoldable as it stands. Is there a RegEx I can modify somewhere to allow multi-line parentheses content to be identified as a collapsible island?