Skip to content

Commit 402d8b9

Browse files
committed
Extract get_layout() from serve_layout()
1 parent 9283b66 commit 402d8b9

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

dash/dash.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,15 +907,22 @@ def index_string(self, value: str) -> None:
907907
self._index_string = value
908908

909909
@with_app_context
910-
def serve_layout(self):
911-
layout = self._layout_value()
910+
def get_layout(self):
911+
"""Return the resolved layout with all hooks applied.
912912
913+
This is the canonical way to obtain the app's layout — it
914+
calls the layout function (if callable), includes extra
915+
components, and runs layout hooks.
916+
"""
917+
layout = self._layout_value()
913918
for hook in self._hooks.get_hooks("layout"):
914919
layout = hook(layout)
920+
return layout
915921

922+
def serve_layout(self):
916923
# TODO - Set browser cache limit - pass hash into frontend
917924
return flask.Response(
918-
to_json(layout),
925+
to_json(self.get_layout()),
919926
mimetype="application/json",
920927
)
921928

0 commit comments

Comments
 (0)