22
33define ( [
44 'modules/default/defaultview' ,
5- 'src/util/domdeferred ' ,
5+ 'src/util/util ' ,
66 'src/util/api' ,
77 'src/util/typerenderer' ,
8- 'src/util/color'
8+ 'src/util/color' ,
9+ 'sprintf'
910] , function ( Default ,
10- DomDeferred ,
11+ Util ,
1112 API ,
1213 Renderer ,
13- Color ) {
14+ Color ,
15+ sprintf ) {
1416
1517 function View ( ) {
1618 }
@@ -86,31 +88,31 @@ define([
8688
8789 var that = this ,
8890 sprintfVal = this . module . getConfiguration ( 'sprintf' ) ,
89- sprintfOrder = this . module . getConfiguration ( 'sprintfOrder' ) ;
90-
91- if ( sprintfVal && sprintfVal != '' ) {
92-
93- try {
94- require ( [ 'sprintf' ] , function ( sprintf ) {
95-
91+ rendererOptions = Util . evalOptions ( this . module . getConfiguration ( 'rendererOptions' ) ) || { } ;
92+ if ( sprintfVal ) {
93+ if ( rendererOptions ) {
94+ var prom = [ ] ;
95+ for ( var i in that . values ) {
96+ prom . push ( this . renderVal ( that . values [ i ] , rendererOptions ) ) ;
97+ }
98+ Promise . all ( prom ) . then ( function ( rendered ) {
99+ var args = [ sprintfVal ] . concat ( rendered ) ;
100+ that . fillWithVal ( sprintf . sprintf . apply ( null , args ) ) ;
101+ } ) ;
102+ } else {
103+ try {
96104 var args = [ sprintfVal ] ;
97105 for ( var i in that . values ) {
98106 args . push ( that . values [ i ] ) ;
99107 }
100-
101108 val = sprintf . sprintf . apply ( this , args ) ;
102-
103- that . fillWithVal ( val ) ;
104- } ) ;
105-
106- } catch ( e ) {
107-
108- that . fillWithVal ( val ) ;
109-
109+ that . fillWithVal ( val , rendererOptions ) ;
110+ } catch ( e ) {
111+ that . fillWithVal ( val , rendererOptions ) ;
112+ }
110113 }
111-
112114 } else {
113- that . fillWithVal ( val ) ;
115+ that . fillWithVal ( val , rendererOptions ) ;
114116 }
115117 } ,
116118
@@ -119,7 +121,18 @@ define([
119121 this . dom . scrollTop ( scroll_height ) ;
120122 } ,
121123
122- fillWithVal : function ( val ) {
124+ renderVal : function ( val , options ) {
125+ var $span = $ ( '<span>' ) ;
126+ return Renderer . render ( $span , val , options )
127+ . then ( function ( ) {
128+ return $span . html ( ) ;
129+ } )
130+ . catch ( function ( ) {
131+ return '[failed]' ;
132+ } ) ;
133+ } ,
134+
135+ fillWithVal : function ( val , rendererOptions ) {
123136
124137 var valign = this . module . getConfiguration ( 'valign' ) ;
125138 var align = this . module . getConfiguration ( 'align' ) ;
@@ -168,11 +181,9 @@ define([
168181 this . _scrollDown ( ) ;
169182
170183 var that = this ;
171- Renderer . render ( div , val ) . then ( function ( ) {
184+ Renderer . render ( div , val , rendererOptions ) . then ( function ( ) {
172185 that . _scrollDown ( ) ;
173186 } ) ;
174-
175- DomDeferred . notify ( div ) ;
176187 }
177188
178189 } ) ;
0 commit comments