Skip to content

Commit ee70d19

Browse files
committed
feat(data): leverage other modules
BREAKING CHANGE: options.data deprecated Use gulp-template or another similar library instead
1 parent ff776c1 commit ee70d19

File tree

4 files changed

+33
-72
lines changed

4 files changed

+33
-72
lines changed

README.md

Lines changed: 26 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -632,26 +632,27 @@ var angularModule = ngClassify(coffeeScriptClass);
632632

633633

634634
#### content
635-
Type: `String`
636-
Default: `undefined`
635+
*Required*
636+
Type: `String`
637+
Default: `undefined`
637638

638639
The content that may contain CoffeeScript classes to convert to AngularJS modules
639640

640641

641642
#### options
642-
Type: `Object`
643+
Type: `Object`
643644

644645

645646
##### options.appName
646-
Type: `String`
647-
Default: `'app'`
647+
Type: `String`
648+
Default: `'app'`
648649

649650
The name of the AngularJS app
650651

651652

652653
##### options.prefix
653-
Type: `String`
654-
Default: `''`
654+
Type: `String`
655+
Default: `''`
655656

656657
To avoid potential collisions, the moduleType prefix may be set (ex: `options.prefix = 'Ng'`)
657658
```coffee
@@ -661,81 +662,49 @@ class Home extends Ng.Controller
661662
```
662663

663664

664-
##### options.data
665-
Type: `Object`
666-
Default `undefined`
667-
668-
An object used for compiling [Lo-Dash templates](http://lodash.com/docs#template).
669-
If the CoffeeScript file contains Lo-Dash template methods, they will be compiled prior to ng-classify with this object.
670-
671-
The following shows an example of conditionally including the AngularJS module, ngMockE2E, if the environment is `'dev'`.
672-
It will not be included if environment is anything other than `'dev'`.
673-
674-
```coffee
675-
class App extends App
676-
@constructor = [
677-
'ngAnimate'
678-
<% if (environment === 'dev') { %>'ngMockE2E'<% } %>
679-
'ngRoute'
680-
]
681-
```
682-
683-
The above class would be compiled using the command below.
684-
```coffee
685-
ngClassify = require 'ng-classify'
686-
coffeeScriptClass = '{{CoffeeScript Class as a String}}'
687-
688-
options =
689-
data:
690-
environment: 'dev'
691-
692-
angularModule = ngClassify coffeeScriptClass, options
693-
```
694-
695-
696665
##### options.animation
697-
Type: `Object`
698-
Default: `{format: 'spinalCase', prefix: '.'}`
666+
Type: `Object`
667+
Default: `{format: 'spinalCase', prefix: '.'}`
699668

700669

701670
##### options.constant
702-
Type: `Object`
703-
Default: `{format: 'screamingSnakeCase'}`
671+
Type: `Object`
672+
Default: `{format: 'screamingSnakeCase'}`
704673

705674

706675
##### options.controller
707-
Type: `Object`
708-
Default: `{format: 'camelCase', suffix: 'Controller'}`
676+
Type: `Object`
677+
Default: `{format: 'camelCase', suffix: 'Controller'}`
709678

710679

711680
##### options.directive
712-
Type: `Object`
713-
Default: `{format: 'camelCase'}`
681+
Type: `Object`
682+
Default: `{format: 'camelCase'}`
714683

715684

716685
##### options.factory
717-
Type: `Object`
718-
Default: `{format: 'upperCamelCase'}`
686+
Type: `Object`
687+
Default: `{format: 'upperCamelCase'}`
719688

720689

721690
##### options.filter
722-
Type: `Object`
723-
Default: `{format: 'camelCase'}`
691+
Type: `Object`
692+
Default: `{format: 'camelCase'}`
724693

725694

726695
##### options.provider
727-
Type: `Object`
728-
Default: `{format: 'camelCase', suffix: 'Provider'}`
696+
Type: `Object`
697+
Default: `{format: 'camelCase', suffix: 'Provider'}`
729698

730699

731700
##### options.service
732-
Type: `Object`
733-
Default: `{format: 'camelCase', suffix: 'Service'}`
701+
Type: `Object`
702+
Default: `{format: 'camelCase', suffix: 'Service'}`
734703

735704

736705
##### options.value
737-
Type: `Object`
738-
Default: `{format: 'camelCase'}`
706+
Type: `Object`
707+
Default: `{format: 'camelCase'}`
739708

740709

741710
### Supported Formats

gulpfile.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

index.coffee

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
_ = require 'lodash'
21
classDetails = require './lib/classDetails'
32
formatOptions = require './lib/formatOptions'
43
moduleDetails = require './lib/moduleDetails'
@@ -9,14 +8,13 @@ module.exports = (content, options) ->
98
formatOpts = formatOptions options
109
opts = moduleOptions formatOpts, options
1110
modTypes = moduleTypes opts.prefix
12-
content = _.template content, opts.data if opts.data
1311
appName = opts.appName
1412
details = classDetails content, modTypes
15-
modules = []
1613
contentLines = content.split '\n'
1714

1815
# take the following class line
1916
# class Home extends Controler
17+
#
2018
# the following will result in
2119
# class Home
2220
getTrimmedContent = (contentLines, position) ->
@@ -36,12 +34,12 @@ module.exports = (content, options) ->
3634
lines
3735

3836
# add appName to moduleDetails
39-
details.forEach (detail) ->
37+
modules = for detail in details
4038
detail.appName = appName
4139
modDetails = moduleDetails detail, opts
4240
contentLines = getTrimmedContent contentLines, detail.position
43-
44-
modules.push modDetails
41+
42+
modDetails
4543

4644
ngClassified = contentLines.join '\n'
4745
ngClassified += '\n\n' if modules.length isnt 0

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
},
2424
"dependencies": {
2525
"coffee-script": "~1.7.1",
26-
"lodash": "~2.4.1",
2726
"node.extend": "~1.0.10"
2827
},
2928
"devDependencies": {
30-
"conventional-changelog": "~0.0.9",
31-
"gulp": "~3.6.2",
29+
"conventional-changelog": "~0.0.11",
30+
"gulp": "~3.8.0",
3231
"gulp-jasmine": "~0.2.0",
33-
"gulp-util": "~2.2.14"
32+
"gulp-util": "~2.2.17"
3433
},
3534
"scripts": {
3635
"test": "gulp test"

0 commit comments

Comments
 (0)