|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
|
|
|
import os
|
|
|
from pathlib import Path
|
|
|
-from typing import Iterable, Optional, Type
|
|
|
+from typing import Dict, Iterable, Optional, Type, Union
|
|
|
|
|
|
from reflex import constants
|
|
|
from reflex.compiler import templates, utils
|
|
@@ -19,6 +19,7 @@ from reflex.config import get_config
|
|
|
from reflex.state import BaseState
|
|
|
from reflex.style import LIGHT_COLOR_MODE
|
|
|
from reflex.utils.imports import ImportVar
|
|
|
+from reflex.vars import Var
|
|
|
|
|
|
|
|
|
def _compile_document_root(root: Component) -> str:
|
|
@@ -299,11 +300,17 @@ def _compile_tailwind(
|
|
|
)
|
|
|
|
|
|
|
|
|
-def compile_document_root(head_components: list[Component]) -> tuple[str, str]:
|
|
|
+def compile_document_root(
|
|
|
+ head_components: list[Component],
|
|
|
+ html_lang: Optional[str] = None,
|
|
|
+ html_custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
|
|
|
+) -> tuple[str, str]:
|
|
|
"""Compile the document root.
|
|
|
|
|
|
Args:
|
|
|
head_components: The components to include in the head.
|
|
|
+ html_lang: The language of the document, will be added to the html root element.
|
|
|
+ html_custom_attrs: custom attributes added to the html root element.
|
|
|
|
|
|
Returns:
|
|
|
The path and code of the compiled document root.
|
|
@@ -312,7 +319,9 @@ def compile_document_root(head_components: list[Component]) -> tuple[str, str]:
|
|
|
output_path = utils.get_page_path(constants.PageNames.DOCUMENT_ROOT)
|
|
|
|
|
|
# Create the document root.
|
|
|
- document_root = utils.create_document_root(head_components)
|
|
|
+ document_root = utils.create_document_root(
|
|
|
+ head_components, html_lang=html_lang, html_custom_attrs=html_custom_attrs
|
|
|
+ )
|
|
|
|
|
|
# Compile the document root.
|
|
|
code = _compile_document_root(document_root)
|