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
166166import { parseTemplate } from ' @hyperse/html-webpack-plugin-loader' ;
167167
168168// Parse and modify HTML template in one go
169- const modifiedHtml = parseTemplate (htmlSource , templateOptions );
169+ const modifiedHtml = parseTemplate (htmlSource , templateOptions ). serialize () ;
170170```
171171
172172The ` 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(
4747 'const parseTemplate = ' + parseTemplate . toString ( ) + ';' ,
4848 'const source = ' + JSON . stringify ( source ) + ';' ,
4949 'module.exports = (function(templateParams) { ' ,
50- 'return parseTemplate(source, templateParams || {});' ,
50+ 'return parseTemplate(source, templateParams || {}).serialize() ;' ,
5151 '});' ,
5252 ] . join ( '' ) ;
5353}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { TemplateParser } from './TemplateParser.js';
1010export const parseTemplate = (
1111 htmlSource : string ,
1212 options : TemplateOptions = { }
13- ) : string => {
13+ ) : TemplateParser => {
1414 const parser = new TemplateParser ( htmlSource ) ;
1515
1616 if ( options . title ) {
@@ -49,5 +49,5 @@ export const parseTemplate = (
4949 parser . upsertBodyScripts ( options . bodyScripts ) ;
5050 }
5151
52- return parser . serialize ( ) ;
52+ return parser ;
5353} ;
You can’t perform that action at this time.
0 commit comments