angular-ui / AngularJS-sublime-package

AngularJS code completion, snippets, go to definition, quick panel search, and more.
MIT License
1.42k stars 169 forks source link

Could you help me write a new snippet? #68

Closed gkatsanos closed 10 years ago

gkatsanos commented 10 years ago

I am using ui-router and I'd like to write a snippet for it's config syntax.. https://github.com/angular-ui/ui-router

myApp.config(function($stateProvider) {
  $stateProvider
    .state('index', {
      url: "",
      views: {
        "viewA": { template: "index.viewA" },
        "viewB": { template: "index.viewB" }
      }
    })
    .state('route1', {
      url: "/route1",
      views: {
        "viewA": { template: "route1.viewA" },
        "viewB": { template: "route1.viewB" }
      }
    })
    .state('route2', {
      url: "/route2",
      views: {
        "viewA": { template: "route2.viewA" },
        "viewB": { template: "route2.viewB" }
      }
    })
});
subhaze commented 10 years ago

It looks like you might want to have two snippets and you can save these in your Packages/User folder as some-name.sublime-snippet.

Below are some examples:

This is triggered via ui-config-state

<snippet>
    <content><![CDATA[
config(function(\$stateProvider) {
  \$stateProvider
    .state('$1', {
      url: "$2",
      views: {
        "$3": { template: "$1.$3" },
        "$4": { template: "$1.$4" }
      }
    })$5
});
]]></content>
    <tabTrigger>ui-config-state</tabTrigger>
    <scope>source.js</scope>
    <description>Angular.js ui-router config</description>
</snippet>

This is triggered via ui-state

<snippet>
    <content><![CDATA[
.state('$1', {
  url: "$2",
  views: {
    "$3": { template: "$1.$3" },
    "$4": { template: "$1.$4" }
  }
})$5
]]></content>
    <tabTrigger>ui-state</tabTrigger>
    <scope>source.js</scope>
    <description>Angular.js ui-router state</description>
</snippet>
gkatsanos commented 10 years ago

That's awesome, I was trying to make an "autocomplete" instead... Thanks a million.