Skip to content

Commit

Permalink
Adding NetBeans 8 code templates.
Browse files Browse the repository at this point in the history
I created some templates for NetBeans based on the Brackets snippets (similar templating markup).
  • Loading branch information
p0lar-bear committed May 31, 2017
1 parent 54b8a8a commit 75840eb
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 8 deletions.
52 changes: 44 additions & 8 deletions a1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
Note: Regarding dependency injection, see [Manually Identify Dependencies](#manual-annotating-for-dependency-injection).

Note: Note that the directive's controller is outside the directive's closure. This style eliminates issues where the injection gets created as unreachable code after a `return`.

Note: Life-style hooks were introduced in Angular 1.5. Initialization logic that relies on bindings being present should be put in the controller's $onInit() method, which is guarranteed to always be called after the bindings have been assigned.

```html
Expand Down Expand Up @@ -1289,14 +1289,14 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
var vm = this;
vm.min = 3;
vm.$onInit = onInit;

//////////

console.log('CTRL: $scope.vm.min = %s', $scope.vm.min);
console.log('CTRL: $scope.vm.max = %s', $scope.vm.max); // undefined in Angular 1.5+
console.log('CTRL: vm.min = %s', vm.min);
console.log('CTRL: vm.max = %s', vm.max); // undefined in Angular 1.5+

// Angular 1.5+ does not bind attributes until calling $onInit();
function onInit() {
console.log('CTRL-onInit: $scope.vm.min = %s', $scope.vm.min);
Expand Down Expand Up @@ -1362,7 +1362,7 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
var vm = this;
vm.min = 3;
vm.$onInit = onInit;

function onInit() = {
console.log('CTRL: vm.min = %s', vm.min);
console.log('CTRL: vm.max = %s', vm.max);
Expand Down Expand Up @@ -2474,8 +2474,8 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
### Run Blocks
###### [Style [Y171](#style-y171)]
- Any code that needs to run when an application starts should be declared in a factory, exposed via a function, and injected into the [run block](https://docs.angularjs.org/guide/module#module-loading-dependencies).
- Any code that needs to run when an application starts should be declared in a factory, exposed via a function, and injected into the [run block](https://docs.angularjs.org/guide/module#module-loading-dependencies).
- Consider using manual bootstrapping techniques, as an alternative for logic that must run prior to running the Angular app.
*Why?*: Code directly in a run block can be difficult to test. Placing in a factory makes it easier to abstract and mock.
Expand Down Expand Up @@ -3168,9 +3168,45 @@ Use file templates or snippets to help follow consistent styles and patterns. He
ngservice // creates an Angular service
ngfilter // creates an Angular filter
```
**[Back to top](#table-of-contents)**
### NetBeans 8
###### [Style [Y258](#style-y258)]
- [NetBeans](https://netbeans.org/) templates that follow these styles and guidelines.
- Download the [NetBeans Angular snippets](assets/netbeans-angular-snippets).
**NOTE:** Make sure the XML file is contained in the same folder ancestry as the repository!
- Create a zip of the netbeans-angular-snippets folder structure.
*The `config` folder, `build.info`, and `enabledItems.info` should be in the root of the zip.*
- In NetBeans, open the **Options** menu (**Tools** > **Options**)
- Click the **Import** button in the bottom left corner of the window.
- Browse to the zip file you created.
- Make sure The "All" and/or "Editor" options are checked.
- Click **OK** and close the Options dialog.
- In a javascript file, type these trigger words followed by `TAB`:
```javascript
// These are full file snippets containing an IIFE
ngcontroller // creates an Angular controller
ngdirective // creates an Angular directive
ngfactory // creates an Angular factory
ngapp // creates an Angular module setter
ngservice // creates an Angular service
ngfilter // creates an Angular filter

// These are partial snippets intended to chained
ngmodule // creates an Angular module getter
ngstate // creates an Angular UI Router state definition
ngconfig // defines a configuration phase function
ngrun // defines a run phase function
ngwhen // defines an Angular ngRoute 'when' definition
ngtranslate // uses $translate service with its promise
```
## Yeoman Generator
###### [Style [Y260](#style-y260)]
Expand Down
4 changes: 4 additions & 0 deletions a1/assets/netbeans-angular-templates/build.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NetbeansBuildnumber=201609300101
ProductVersion=NetBeans IDE 8.2 (Build 201609300101)
OS=Windows 7, 6.1, amd64
Java=1.8.0_102, Java HotSpot(TM) 64-Bit Server VM, 25.102-b14
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE codetemplates PUBLIC "-//NetBeans//DTD Editor Code Templates settings 1.0//EN" "http://www.netbeans.org/dtds/EditorCodeTemplates-1_0.dtd">
<codetemplates>
<codetemplate abbreviation="ngcontroller" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[(function() {
'use strict';
angular
.module('${module}')
.controller('${Controller}', ${Controller});
${Controller}.$inject = ['${dependencies}'];
/* @ngInject */
function ${Controller}(${dependencies}){
var vm = this;
vm.${property} = '${Controller}';
${cursor}
activate();
////////////////
function activate() {
}
}
})();
]]></code>
<description><![CDATA[AngularJS controller]]></description>
</codetemplate>
<codetemplate abbreviation="ngstate" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[.state('${state}', {
url: '${/url}',
templateUrl: '${template}.html',
controller: '${Controller}',
controllerAs: '${vm}'
})${cursor}
]]></code>
<description><![CDATA[AngularJS UI-Router state]]></description>
</codetemplate>
<codetemplate abbreviation="ngvalue" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[.value('${name}', ${value});]]></code>
<description><![CDATA[AngularJS value]]></description>
</codetemplate>
<codetemplate abbreviation="ngtranslate" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[$translate(['${key1}']).then(function(translations){
${value} = translations['${key1}'];
});]]></code>
<description><![CDATA[AngularJS $translate service]]></description>
</codetemplate>
<codetemplate abbreviation="ngdirective" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[(function () {
'use strict';
angular
.module('${module}')
.directive('${directive}', ${directive});
${2:directive}.$inject = ['${dependencies}'];
/* @ngInject */
function ${directive}(${dependencies}) {
var directive = {
bindToController: true,
controller: ${Controller},
controllerAs: '${vm}',
link: link,
restrict: 'A',
scope: {}
};
return directive;
function link(scope, element, attrs, controller) {
${cursor}
}
}
${Controller}.$inject = ['${dependencies}'];
/* @ngInject */
function ${Controller}(${dependencies}) {
}
})();
]]></code>
<description><![CDATA[AngularJS directive]]></description>
</codetemplate>
<codetemplate abbreviation="ngmodule" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[angular
.module('${module}')${cursor}]]></code>
<description><![CDATA[AngularJS module getter]]></description>
</codetemplate>
<codetemplate abbreviation="ngwhen" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[.when('/${url}', {
templateUrl: '${template}.html',
controller: '${Controller}',
controllerAs: '${vm}'
})${cursor}
]]></code>
<description><![CDATA[AngularJS ngRoute 'when']]></description>
</codetemplate>
<codetemplate abbreviation="ngrun" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[.run(${runFn})
${runFn}.$inject = ['${dependencies}'];
/* @ngInject */
function ${runFn} (${dependencies}) {
${cursor}
}]]></code>
<description><![CDATA[AngularJS run phase function]]></description>
</codetemplate>
<codetemplate abbreviation="ngapp" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[(function () {
'use strict';
angular
.module('${module}', [
${cursor}
]);
})();
]]></code>
<description><![CDATA[AngularJS module definition]]></description>
</codetemplate>
<codetemplate abbreviation="ngservice" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[(function () {
'use strict';
angular
.module('${module}')
.service('${2:Service}', ${2:Service});
${2:Service}.$inject = ['${3:dependencies}'];
/* @ngInject */
function ${2:Service}(${3:dependencies}) {
this.${4:func} = ${4:func};
////////////////
function ${4:func}() {
${5:}
}
}
})();
]]></code>
<description><![CDATA[AngularJS service]]></description>
</codetemplate>
<codetemplate abbreviation="ngconfig" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[.config(${configuration})
${configuration}.$inject = ['${dependencies}'];
/* @ngInject */
function ${configuration} (${dependencies}) {
${cursor}
}]]></code>
<description><![CDATA[AngularJS config phase function]]></description>
</codetemplate>
<codetemplate abbreviation="ngfilter" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[(function () {
'use strict';
angular
.module('${module}')
.filter('${filter}', ${filter});
function ${filter}() {
${cursor}
return ${filter}Filter;
////////////////
function ${filter}Filter(${filter_params}) {
return ${filter_params};
};
}
})();
]]></code>
<description><![CDATA[AngularJS filter]]></description>
</codetemplate>
<codetemplate abbreviation="ngfactory" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[(function () {
'use strict';
angular
.module('${module}')
.factory('${factory}', ${factory});
${factory}.$inject = ['${dependencies}'];
/* @ngInject */
function ${Factory}(${dependencies}){
var exports = {
${func}: ${func}
};
${cursor}
return exports;
////////////////
function ${func}() {
}
}
})();
]]></code>
<description><![CDATA[AngularJS factory]]></description>
</codetemplate>
<codetemplate abbreviation="ngconst" contexts="JavaScript-Code" xml:space="preserve">
<code><![CDATA[.constant('${name}', ${value});
]]></code>
<description><![CDATA[AngularJS constant]]></description>
</codetemplate>
</codetemplates>
1 change: 1 addition & 0 deletions a1/assets/netbeans-angular-templates/enabledItems.info
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EditorCode Templates

0 comments on commit 75840eb

Please sign in to comment.