@@ -14,24 +14,36 @@ angular.module('angular-templates', []).config([
14
14
function ( $provide ) {
15
15
var templatesFileExtension = [ 'html' , 'tpl' , 'tmpl' , 'template' , 'view' ] ;
16
16
17
- $provide . decorator ( '$templateCache' , [ '$delegate' , function ( $delegate ) {
18
- var originalGet = $delegate . get ;
17
+ $provide . decorator ( '$templateCache' , [ '$delegate' , '$angularTemplatesSettings' ,
18
+ function ( $delegate , $angularTemplatesSettings ) {
19
+ var originalGet = $delegate . get ;
19
20
20
- $delegate . get = function ( templatePath ) {
21
- var originalResult = originalGet ( templatePath ) ;
21
+ $delegate . get = function ( templatePath ) {
22
+ var originalResult = originalGet ( templatePath ) ;
22
23
23
- if ( angular . isUndefined ( originalResult ) ) {
24
- var fileExtension = ( ( templatePath . split ( '.' ) || [ ] ) . pop ( ) || '' ) . toLowerCase ( ) ;
24
+ if ( angular . isUndefined ( originalResult ) ) {
25
+ var fileExtension = ( ( templatePath . split ( '.' ) || [ ] ) . pop ( ) || '' ) . toLowerCase ( ) ;
25
26
26
- if ( templatesFileExtension . indexOf ( fileExtension ) > - 1 ) {
27
- throw new Error ( '[angular-meteor][err][404] ' + templatePath + ' - HTML template does not exists!' ) ;
27
+ if ( templatesFileExtension . indexOf ( fileExtension ) > - 1 ) {
28
+ function getMsg ( type ) {
29
+ return '[angular-meteor][err][404] ' + templatePath + ' - HTML template does not exists! You can disable this ' + type + ' by following this guide http://www.angular-meteor.com/api/1.3.11/templates' ;
30
+ }
31
+
32
+ if ( $angularTemplatesSettings . error === true ) {
33
+ throw new Error ( getMsg ( 'error' ) ) ;
34
+ } else if ( $angularTemplatesSettings . warning === true ) {
35
+ console . warn ( getMsg ( 'warning' ) ) ;
36
+ }
37
+ }
28
38
}
29
- }
30
39
31
- return originalResult ;
32
- } ;
40
+ return originalResult ;
41
+ } ;
33
42
34
- return $delegate ;
43
+ return $delegate ;
35
44
} ] ) ;
36
45
}
37
- ] ) ;
46
+ ] ) . constant ( '$angularTemplatesSettings' , {
47
+ error : true ,
48
+ warning : true
49
+ } ) ; ;
0 commit comments