Skip to content

Commit c9a062f

Browse files
committed
feat(wrappedClasses): add support for wrapped classes
ex: define -> class Home extends Controller
1 parent f54ea5e commit c9a062f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/classDetails.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ module.exports = (content, moduleTypes) ->
6262
classDetails.push {className, moduleType, appName, parameters: [], position}
6363
processNodes body.expressions
6464

65+
# check to see if there exists a wrapper function (e.g. define, etc.)
66+
hasWrapper = node?.args?[0]?.body?.expressions?
67+
68+
return if hasWrapper
69+
processNodes node.args[0].body.expressions
70+
6571
base = node.base
6672
hasProperties = base?.properties
6773

test/ng-classify.spec.coffee

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,4 +921,26 @@ describe 'ng-classify', ->
921921
.controller('adminController', [Admin])
922922
'''
923923

924+
expect(result).toEqual(expectation)
925+
926+
it 'should compile with function wrapped classes', ->
927+
input = '''
928+
define ->
929+
class Admin extends Controller('app.controllers')
930+
constructor: ($scope, someService) ->
931+
$scope.coolMethod = someService.coolMethod()
932+
'''
933+
934+
result = ngClassify input
935+
936+
expectation = '''
937+
define ->
938+
class Admin
939+
constructor: ($scope, someService) ->
940+
$scope.coolMethod = someService.coolMethod()
941+
942+
angular.module('app.controllers')
943+
.controller('adminController', ['$scope', 'someService', Admin])
944+
'''
945+
924946
expect(result).toEqual(expectation)

0 commit comments

Comments
 (0)