File tree Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @hyperse/html-webpack-plugin-loader " : patch
3
+ ---
4
+
5
+ improve parseTemplate api
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ A utility function that provides a convenient way to parse and modify HTML templ
166
166
import { parseTemplate } from ' @hyperse/html-webpack-plugin-loader' ;
167
167
168
168
// Parse and modify HTML template in one go
169
- const modifiedHtml = parseTemplate (htmlSource , templateOptions );
169
+ const modifiedHtml = parseTemplate (htmlSource , templateOptions ). serialize () ;
170
170
```
171
171
172
172
The ` parseTemplate ` function is a shorthand for creating a ` TemplateParser ` instance and applying all template modifications at once. It accepts two parameters:
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export default function htmlLoader(
47
47
'const parseTemplate = ' + parseTemplate . toString ( ) + ';' ,
48
48
'const source = ' + JSON . stringify ( source ) + ';' ,
49
49
'module.exports = (function(templateParams) { ' ,
50
- 'return parseTemplate(source, templateParams || {});' ,
50
+ 'return parseTemplate(source, templateParams || {}).serialize() ;' ,
51
51
'});' ,
52
52
] . join ( '' ) ;
53
53
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { TemplateParser } from './TemplateParser.js';
10
10
export const parseTemplate = (
11
11
htmlSource : string ,
12
12
options : TemplateOptions = { }
13
- ) : string => {
13
+ ) : TemplateParser => {
14
14
const parser = new TemplateParser ( htmlSource ) ;
15
15
16
16
if ( options . title ) {
@@ -49,5 +49,5 @@ export const parseTemplate = (
49
49
parser . upsertBodyScripts ( options . bodyScripts ) ;
50
50
}
51
51
52
- return parser . serialize ( ) ;
52
+ return parser ;
53
53
} ;
You can’t perform that action at this time.
0 commit comments