File tree Expand file tree Collapse file tree 3 files changed +47
-6
lines changed Expand file tree Collapse file tree 3 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,9 @@ module.exports = (content, options) ->
17
17
# add appName to moduleDetails
18
18
details .forEach (detail) ->
19
19
detail .appName = appName
20
+ modDetails = moduleDetails detail, opts
20
21
21
- modules .push moduleDetails detail, opts
22
+ modules .push modDetails
22
23
23
24
# remove angular moduleTypes from content
24
25
modTypes .forEach (moduleType) ->
Original file line number Diff line number Diff line change 1
1
applyCaseFilters = require ' ./applyCaseFilters'
2
2
3
3
module .exports = (details , options ) ->
4
- format = options .formats [details .moduleType .toLowerCase ()]
5
- parts = format .split / {{(. *? )}}/
6
- compiled = []
4
+ prefixLessModuleType = details .moduleType .split (' .' )[- 1 .. ][0 ]
5
+ format = options .formats [prefixLessModuleType .toLowerCase ()]
6
+ parts = format .split / {{(. *? )}}/
7
+ compiled = []
7
8
8
9
parts .forEach (part) ->
9
10
filters = part .split ' |'
@@ -16,7 +17,8 @@ module.exports = (details, options) ->
16
17
17
18
if filters .length > 1
18
19
filters = filters .slice (1 )
19
- detail = applyCaseFilters detail, filters
20
+ key = if component is ' moduleType' then prefixLessModuleType else detail
21
+ detail = applyCaseFilters key, filters
20
22
21
23
compiled .push if detail then detail else component
22
24
Original file line number Diff line number Diff line change @@ -647,4 +647,42 @@ describe 'ng-classify', ->
647
647
constructor: (baaa) ->
648
648
'''
649
649
650
- result = ngClassify input
650
+ result = ngClassify input
651
+
652
+ it ' should compile with a moduleType prefix' , ->
653
+ input = '''
654
+ class Home extends Ng.Controller
655
+ constructor: ($log) ->
656
+ $log.info 'controller with prefix'
657
+ '''
658
+
659
+ result = ngClassify input, prefix : ' Ng'
660
+
661
+ expectation = '''
662
+ class Home
663
+ constructor: ($log) ->
664
+ $log.info 'controller with prefix'
665
+
666
+ angular.module('app').controller 'homeController', ['$log', Home]
667
+ '''
668
+
669
+ expect (result).toEqual (expectation)
670
+
671
+ it ' should compile with a namespace with an ending period (.)' , ->
672
+ input = '''
673
+ class Home extends Ng.My.Controller
674
+ constructor: ($log) ->
675
+ $log.info 'controller with prefix'
676
+ '''
677
+
678
+ result = ngClassify input, prefix : ' Ng.My.'
679
+
680
+ expectation = '''
681
+ class Home
682
+ constructor: ($log) ->
683
+ $log.info 'controller with prefix'
684
+
685
+ angular.module('app').controller 'homeController', ['$log', Home]
686
+ '''
687
+
688
+ expect (result).toEqual (expectation)
You can’t perform that action at this time.
0 commit comments