Skip to content

Commit

Permalink
add content pseudo element to builder (#1680)
Browse files Browse the repository at this point in the history
resolves #1659

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Aug 21, 2024
1 parent 213703a commit f624ef2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion taipy/gui/builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# specific language governing permissions and limitations under the License.

from ._api_generator import _ElementApiGenerator
from ._element import html
from ._element import content, html

# separate import for "Page" class so stubgen can properly generate pyi file
from .page import Page
Expand Down
19 changes: 19 additions & 0 deletions taipy/gui/builder/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,22 @@ def __enter__(self):

def __exit__(self, exc_type, exc_value, traceback):
raise RuntimeError(f"Can't use Context Manager for control type '{self._ELEMENT_NAME}'")


class content(_Control):
"""
Create a `content` pseudo-element
Arguments:
None
Examples:
- To generate `content`, use:
```
content()
```
"""

def _render(self, gui: "Gui") -> str:
el = _BuilderFactory.create_element(gui, "content", {})
return f"{el[0]}</{el[1]}>"
22 changes: 22 additions & 0 deletions tests/gui/builder/control/test_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2021-2024 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
import taipy.gui.builder as tgb
from taipy.gui import Gui


def test_content_builder(gui: Gui, test_client, helpers):
with tgb.Page(frame=None) as page:
tgb.content()
expected_list = [
'<PageContent ',
'></PageContent>',
]
helpers.test_control_builder(gui, page, expected_list)

0 comments on commit f624ef2

Please sign in to comment.