8585 console . error ( error ) ;
8686}
8787
88- const renderView = async ( ctx :IContext , viewName :string , initProps ?:any , options ?:TviewOptions ) => {
88+ const renderDom = async ( ctx :IContext , viewName :string , initProps ?:any , options ?:TviewOptions ) => {
8989 const mergeProps = Object . assign ( ctx . state || { } , initProps ) ;
9090 let html = await SrejsInstance . render ( ctx , viewName , mergeProps , options ) ;
9191
@@ -108,6 +108,12 @@ const renderView = async (ctx:IContext, viewName:string, initProps?:any, options
108108 html = await engine . render ( html , state ) ;
109109 }
110110
111+ return html ;
112+ } ;
113+
114+ const renderView = async ( ctx : IContext , viewName : string , initProps ?: any , options ?: TviewOptions ) => {
115+ const html = await renderDom ( ctx , viewName , initProps , options ) ;
116+
111117 ctx . type = 'text/html' ;
112118 ctx . body = html ;
113119} ;
@@ -137,6 +143,9 @@ export default (): TPlugin => ({
137143 async react ( viewName :string , initProps ?:any , options ?:TviewOptions ) {
138144 await renderView ( this , viewName , initProps , options ) ;
139145 } ,
146+ async reactDom ( viewName :string , initProps ?:any , options ?:TviewOptions ) : Promise < string > {
147+ return await renderDom ( this , viewName , initProps , options ) ;
148+ } ,
140149 } ,
141150
142151} ) ;
0 commit comments