Skip to content

Commit 3916781

Browse files
HTML Template is now baked-in using Grunt, so no need to modify "templateUrl" any more.
1 parent 3ec9d70 commit 3916781

File tree

9 files changed

+638
-1104
lines changed

9 files changed

+638
-1104
lines changed

Gruntfile.coffee

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = (grunt)->
1010
options:
1111
pretty:true
1212
files:
13-
'dist/abn_tree_template.html':'src/abn_tree_template.jade'
13+
'temp/_template.html':'src/abn_tree_template.jade'
1414
'test/tests_page.html':'test/tests_page.jade'
1515

1616
#
@@ -57,24 +57,41 @@ module.exports = (grunt)->
5757
ng:"1.2.12"
5858

5959

60-
61-
62-
63-
60+
"string-replace":
61+
dev:
62+
files:
63+
#
64+
# substitute the "template html" into an intermediate coffeescript file
65+
# ( to take advantage of triple-quoted strings )
66+
#
67+
'temp/_directive.coffee':'src/abn_tree_directive.coffee'
68+
options:
69+
replacements:[
70+
pattern: "{html}"
71+
replacement_old: "<h1>i am the replacement!</h1>"
72+
replacement: (match, p1, offset, string)->
73+
grunt.file.read('temp/_template.html')
74+
]
6475

6576
coffee:
6677
dev:
6778
options:
6879
bare:true
6980
files:
70-
'dist/abn_tree_directive.js':'src/abn_tree_directive.coffee'
81+
#
82+
# the _temp.coffee file has the "template html" baked-in by Grunt
83+
#
84+
'dist/abn_tree_directive.js':'temp/_directive.coffee'
7185
'test/test_page.js':'test/test_page.coffee'
7286

7387

88+
89+
7490
watch:
91+
7592
jade:
7693
files:['**/*.jade']
77-
tasks:['jade']
94+
tasks:['jade','string-replace']
7895
options:
7996
livereload:true
8097

@@ -84,16 +101,19 @@ module.exports = (grunt)->
84101
options:
85102
livereload:true
86103

87-
88104
coffee:
89105
files:['**/*.coffee']
90-
tasks:['coffee']
106+
tasks:['jade','string-replace','coffee']
91107
options:
92108
livereload:true
93109

94110
grunt.loadNpmTasks 'grunt-contrib-jade'
95111
grunt.loadNpmTasks 'grunt-contrib-coffee'
96112
grunt.loadNpmTasks 'grunt-contrib-watch'
113+
grunt.loadNpmTasks 'grunt-string-replace'
114+
115+
116+
grunt.registerTask 'default', ['jade','string-replace','coffee','watch']
117+
97118

98-
grunt.registerTask 'default', ['jade','coffee','watch']
99119

Gruntfile.js

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/abn_tree_directive.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module = angular.module('angularBootstrapNavTree', []);
55
module.directive('abnTree', function($timeout) {
66
return {
77
restrict: 'E',
8-
templateUrl: '../dist/abn_tree_template.html',
9-
template: "{replace this with template html}",
8+
template: "<ul class=\"nav nav-list nav-pills nav-stacked abn-tree\">\n <li ng-repeat=\"row in tree_rows | filter:{visible:true} track by row.branch.uid\" ng-animate=\"'abn-tree-animate'\" ng-class=\"'level-' + {{ row.level }} + (row.branch.selected ? ' active':'')\" class=\"abn-tree-row\">\n <a ng-click=\"user_clicks_branch(row.branch)\">\n <i ng-class=\"row.tree_icon\" ng-click=\"row.branch.expanded = !row.branch.expanded\" class=\"indented tree-icon\"> </i>\n <span class=\"indented tree-label\">{{ row.label }} </span>\n </a>\n </li>\n</ul>",
109
scope: {
1110
treeData: '=',
1211
onSelect: '&',

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"name": "angular-bootstrap-nav-tree",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"dependencies": {},
55
"devDependencies": {
66
"grunt": "~0.4.1",
77
"grunt-contrib-coffee": "~0.7.0",
88
"grunt-contrib-watch": "~0.5.1",
99
"grunt-contrib-jade": "~0.8.0",
1010
"grunt-string-replace": "~0.2.7"
11-
}
11+
},
12+
"keywords":["angularjs","bootstrap","tree","widget"],
13+
"licence":"MIT"
1214
}

src/abn_tree_directive.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ module = angular.module 'angularBootstrapNavTree',[]
33

44
module.directive 'abnTree',($timeout)->
55
restrict:'E'
6-
templateUrl: '../dist/abn_tree_template.html' # <--- CHANGE THIS
6+
7+
#templateUrl: '../dist/abn_tree_template.html' # <--- another way to do this
78

8-
template: "{replace this with template html}"
9+
template: """{html}""" # will be replaced by Grunt, during build, with the actual Template HTML
910

1011
scope:
1112
treeData:'='

src/abn_tree_template.jade

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
ul.nav.nav-list.nav-pills.nav-stacked.abn-tree
33

4-
54
li.abn-tree-row(
65
ng-repeat='row in tree_rows | filter:{visible:true} track by row.branch.uid'
76
ng-animate="'abn-tree-animate'"
@@ -16,6 +15,3 @@ ul.nav.nav-list.nav-pills.nav-stacked.abn-tree
1615
)
1716

1817
span.indented.tree-label {{ row.label }}
19-
20-
21-

0 commit comments

Comments
 (0)