@@ -90,7 +90,7 @@ export class StackblitzWriter {
90
90
91
91
// TODO(josephperrott): Prevent including assets to be manually checked.
92
92
if ( data . selectorName === 'icon-svg-example' ) {
93
- this . _readFile ( form , data , 'assets/img/examples/thumbup-icon.svg' , '' ) ;
93
+ this . _readFile ( form , data , 'assets/img/examples/thumbup-icon.svg' , '' , false ) ;
94
94
}
95
95
96
96
Promise . all ( templateContents . concat ( exampleContents ) ) . then ( ( ) => {
@@ -117,22 +117,42 @@ export class StackblitzWriter {
117
117
form . appendChild ( input ) ;
118
118
}
119
119
120
- /** Reads the file and adds its text to the form */
121
- _readFile ( form : HTMLFormElement , data : ExampleData , filename : string , path : string ) : void {
120
+ /**
121
+ * Reads the file and adds its text to the form
122
+ * @param form the html form you are appending to
123
+ * @param data example metadata about the example
124
+ * @param filename file name of the example
125
+ * @param path path to the src
126
+ * @param prependApp whether to prepend the 'app' prefix to the path
127
+ */
128
+ _readFile ( form : HTMLFormElement ,
129
+ data : ExampleData ,
130
+ filename : string ,
131
+ path : string ,
132
+ prependApp = true ) : void {
122
133
this . _http . get ( path + filename ) . toPromise ( ) . then (
123
- response => this . _addFileToForm ( form , data , response . text ( ) , filename , path ) ,
134
+ response => this . _addFileToForm ( form , data , response . text ( ) , filename , path , prependApp ) ,
124
135
error => console . log ( error ) ) ;
125
136
}
126
137
127
- /** Adds the file text to the form. */
138
+ /**
139
+ * Adds the file text to the form.
140
+ * @param form the html form you are appending to
141
+ * @param data example metadata about the example
142
+ * @param content file contents
143
+ * @param filename file name of the example
144
+ * @param path path to the src
145
+ * @param prependApp whether to prepend the 'app' prefix to the path
146
+ */
128
147
_addFileToForm ( form : HTMLFormElement ,
129
148
data : ExampleData ,
130
149
content : string ,
131
150
filename : string ,
132
- path : string ) {
151
+ path : string ,
152
+ prependApp = true ) {
133
153
if ( path == TEMPLATE_PATH ) {
134
154
content = this . _replaceExamplePlaceholderNames ( data , filename , content ) ;
135
- } else {
155
+ } else if ( prependApp ) {
136
156
filename = 'app/' + filename ;
137
157
}
138
158
this . _appendFormInput ( form , `files[${ filename } ]` , this . _appendCopyright ( filename , content ) ) ;
0 commit comments