File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 35
35
*/
36
36
final class AddLiveAttributesSubscriber implements EventSubscriberInterface, ServiceSubscriberInterface
37
37
{
38
+ private const DEFAULT_LOADING_TAG = 'div ' ;
39
+
40
+ private const DEFAULT_LOADING_TEMPLATE = null ;
41
+
38
42
public function __construct (
39
43
private ComponentStack $ componentStack ,
40
44
private TemplateMap $ templateMap ,
@@ -75,14 +79,14 @@ public function onPreRender(PreRenderEvent $event): void
75
79
}
76
80
77
81
$ inputProps = $ event ->getMountedComponent ()->getInputProps ();
78
- $ isDeferred = array_key_exists ('defer ' , $ inputProps );
82
+ $ isDeferred = \ array_key_exists ('defer ' , $ inputProps );
79
83
80
84
if ($ isDeferred ) {
81
85
$ event ->setTemplate ('@LiveComponent/deferred.html.twig ' );
82
86
83
- if ( $ loadingTemplate ) {
84
- $ variables ['loadingTemplate ' ] = $ loadingTemplate ;
85
- }
87
+ $ variables [ ' loadingTag ' ] = $ originalAttributes [ ' loading-tag ' ] ?? self :: DEFAULT_LOADING_TAG ;
88
+ $ variables ['loadingTemplate ' ] = $ originalAttributes [ ' loading-template ' ] ?? self :: DEFAULT_LOADING_TEMPLATE ;
89
+ $ attributes = $ attributes -> without ( ' defer ' , ' loading-element ' , ' loading-template ' );
86
90
}
87
91
}
88
92
Original file line number Diff line number Diff line change 1
- <div {{ attributes }} data-action =" live:connect->live#$render" >
2
- {% if loadingTemplate is defined and loadingTemplate != null %}
3
- {{ include (loadingTemplate ) }}
4
- {% endif %}
5
- </div >
1
+ < {{ loadingTag }} {{ attributes }} data-action="live:connect->live#$render">
2
+ {% block loadingContent %}
3
+ {% if loadingTemplate != null %}
4
+ {{ include (loadingTemplate ) }}
5
+ {% endif %}
6
+ {% endblock %}
7
+ < /{{ loadingTag }}>
You can’t perform that action at this time.
0 commit comments