@@ -106,7 +106,7 @@ function _scripts (scripts, callback) {
106106}
107107
108108function _themeUpdate ( _data ) {
109- const data = _data . replace ( '<template>' , '' ) . replace ( '</template>' , '' )
109+ const data = _data
110110
111111 if ( / b o o t s t r a p 3 .h t m l $ / . test ( location . pathname ) ) {
112112 return data . replace ( / b t n - s e c o n d a r y / g, 'btn-default' )
@@ -151,25 +151,33 @@ function _beautifySource (data) {
151151 let lines = data . split ( '\n' )
152152 const scriptStart = lines . indexOf ( '<script>' )
153153 const scriptEnd = lines . indexOf ( '</script>' , scriptStart )
154- let strings = lines . slice ( scriptStart + 1 , scriptEnd )
154+ const strings = lines . slice ( scriptStart + 1 , scriptEnd )
155+ . map ( s => s . trim ( ) )
156+ const templateStart = lines . indexOf ( '<template>' )
157+ const templateEnd = lines . indexOf ( '</template>' , scriptStart )
158+ const templates = lines . slice ( templateStart + 1 , templateEnd )
159+ . map ( s => s . replace ( / ^ { 2 } / , '' ) )
155160
156- strings = $ . map ( strings , function ( s ) {
157- return $ . trim ( s )
158- } )
159161 /* eslint-disable no-control-regex */
160162 const obj = eval ( `(${ strings . join ( '' ) . replace ( / [ ^ \u0000 - \u007E ] / g, '' )
161163 . replace ( / ^ i n i t \( ( .* ) \) $ / , '$1' ) } )`)
162164
163165 let result = [ ]
166+ const addEmptyLine = ( ) => {
167+ if ( result [ result . length - 1 ] !== '' ) {
168+ result . push ( '' )
169+ }
170+ }
164171
165172 result = result . concat ( $ . map ( obj . links , _getLink ) )
166- result . push ( '' )
173+ addEmptyLine ( )
167174 result = result . concat ( $ . map ( obj . scripts , function ( script ) {
168175 return _getScript ( script , true )
169176 } ) )
170- lines = result . concat ( lines . slice ( scriptEnd + 1 ) )
177+ addEmptyLine ( )
178+ lines = result . concat ( templates , lines . slice ( templateEnd + 1 ) )
171179
172- const mountedStart = lines . indexOf ( ' function mounted() {' )
180+ const mountedStart = lines . indexOf ( ' function mounted () {' )
173181 const mountedEnd = lines . indexOf ( ' }' , mountedStart )
174182
175183 lines [ mountedStart ] = ' $(function() {'
@@ -205,7 +213,9 @@ $(function () {
205213 $ ( '#source' ) . text ( _beautifySource ( data ) )
206214 window . hljs . highlightAll ( )
207215 } else {
208- $ ( '#example' ) . html ( data . replace ( / d a t a - t o g g l e = " t a b l e " / g, ' data-toggle="bootstrap-table"' ) )
216+ $ ( '#example' ) . html ( data
217+ . replace ( '<template>' , '' ) . replace ( '</template>' , '' )
218+ . replace ( / d a t a - t o g g l e = " t a b l e " / g, ' data-toggle="bootstrap-table"' ) )
209219 }
210220 } ,
211221 error ( ) {
0 commit comments