85
85
console . error ( error ) ;
86
86
}
87
87
88
- const renderView = async ( ctx :IContext , viewName :string , initProps ?:any , options ?:TviewOptions ) => {
88
+ const renderDom = async ( ctx :IContext , viewName :string , initProps ?:any , options ?:TviewOptions ) => {
89
89
const mergeProps = Object . assign ( ctx . state || { } , initProps ) ;
90
90
let html = await SrejsInstance . render ( ctx , viewName , mergeProps , options ) ;
91
91
@@ -108,6 +108,12 @@ const renderView = async (ctx:IContext, viewName:string, initProps?:any, options
108
108
html = await engine . render ( html , state ) ;
109
109
}
110
110
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
+
111
117
ctx . type = 'text/html' ;
112
118
ctx . body = html ;
113
119
} ;
@@ -137,6 +143,9 @@ export default (): TPlugin => ({
137
143
async react ( viewName :string , initProps ?:any , options ?:TviewOptions ) {
138
144
await renderView ( this , viewName , initProps , options ) ;
139
145
} ,
146
+ async reactDom ( viewName :string , initProps ?:any , options ?:TviewOptions ) : Promise < string > {
147
+ return await renderDom ( this , viewName , initProps , options ) ;
148
+ } ,
140
149
} ,
141
150
142
151
} ) ;
0 commit comments