-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added angular ng:directive generator
- Loading branch information
Jad Joubran
committed
Aug 14, 2015
1 parent
a7e043f
commit 2b3b58a
Showing
16 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(function(){ | ||
"use strict"; | ||
|
||
angular.module('app.directives').directive( 'DataListing', function() { | ||
|
||
return { | ||
restrict: 'EA', | ||
templateUrl: 'views/directives/data_listing/data_listing.html', | ||
controller: 'DataListingCtrl', | ||
link: function( $scope, element, $attrs ){ | ||
// | ||
} | ||
}; | ||
|
||
}); | ||
|
||
})(); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(function(){ | ||
"use strict"; | ||
|
||
angular.module( 'app.controllers' ).controller( 'DataListingCtrl', function(){ | ||
// | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use File; | ||
|
||
class AngularDirective extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'ng:directive {name}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new directive folder with sample HTML, JS & LESS inside the angular/directives folder.'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$name = $this->argument('name'); | ||
$studly_name = studly_case($name); | ||
|
||
$html = file_get_contents(__DIR__.'/Stubs/AngularDirective/directive.html.stub'); | ||
$js = file_get_contents(__DIR__.'/Stubs/AngularDirective/directive.js.stub'); | ||
$definition = file_get_contents(__DIR__.'/Stubs/AngularDirective/definition.js.stub'); | ||
$less = file_get_contents(__DIR__.'/Stubs/AngularDirective/directive.less.stub'); | ||
|
||
$js = str_replace('{{StudlyName}}', $studly_name, $js); | ||
$definition = str_replace('{{StudlyName}}', $studly_name, $definition); | ||
$definition = str_replace('{{name}}', $name, $definition); | ||
|
||
$folder = __DIR__.'/../../../angular/directives/'.$name; | ||
if (is_dir($folder)) { | ||
$this->info('Folder already exists'); | ||
|
||
return false; | ||
} | ||
|
||
//create folder | ||
File::makeDirectory($folder, 0775, true); | ||
|
||
//create view (.html) | ||
File::put($folder.'/'.$name.'.html', $html); | ||
|
||
//create definition (.js) | ||
File::put($folder.'/definition.js', $js); | ||
|
||
//create controller (.js) | ||
File::put($folder.'/'.$name.'.js', $definition); | ||
|
||
//create less file (.less) | ||
File::put($folder.'/'.$name.'.less', $less); | ||
|
||
$this->info('Directive created successfully.'); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Console/Commands/Stubs/AngularDirective/definition.js.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(function(){ | ||
"use strict"; | ||
|
||
angular.module('app.directives').directive( '{{StudlyName}}', function() { | ||
|
||
return { | ||
restrict: 'EA', | ||
templateUrl: 'views/directives/{{name}}/{{name}}.html', | ||
controller: '{{StudlyName}}Ctrl', | ||
link: function( $scope, element, $attrs ){ | ||
// | ||
} | ||
}; | ||
|
||
}); | ||
|
||
})(); |
Empty file.
8 changes: 8 additions & 0 deletions
8
app/Console/Commands/Stubs/AngularDirective/directive.js.stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(function(){ | ||
"use strict"; | ||
|
||
angular.module( 'app.controllers' ).controller( '{{StudlyName}}Ctrl', function(){ | ||
// | ||
}); | ||
|
||
})(); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters