Skip to content

Commit 31e22a0

Browse files
authored
Merge pull request #2367 from Avaiga/feature/#2263-convert-templates-from-markdown-to-tgb
Feature/#2263 - Convert templates from markdown to tgb
2 parents d536592 + bdf8392 commit 31e22a0

File tree

12 files changed

+51
-64
lines changed

12 files changed

+51
-64
lines changed

taipy/templates/default/hooks/post_gen_project.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,29 @@ def handle_single_page_app():
7777
main_file.write("\n")
7878
main_file.write(" gui = Gui(page=page)\n")
7979

80+
with open(os.path.join(os.getcwd(), "sections", "import.txt"), "a") as import_file:
81+
import_file.write("import taipy.gui.builder as tgb\n")
82+
8083
handle_run_service()
8184

8285
with open(os.path.join(os.getcwd(), "sections", "page_content.txt"), "a") as page_content_file:
8386
page_content_file.write(
84-
'''
85-
page = """
86-
<center>
87-
<|navbar|lov={[("home", "Homepage")]}|>
88-
</center>
87+
"""
88+
with tgb.Page() as page:
89+
tgb.navbar(lov="{[('home', 'Homepage')]}")
8990
9091
"""
91-
'''
9292
)
9393

9494

9595
def handle_multi_page_app(pages):
9696
for page_name in pages:
9797
os.mkdir(os.path.join(os.getcwd(), "pages", page_name))
98-
with open(os.path.join(os.getcwd(), "pages", "page_example", "page_example.md"), "r") as page_md_file:
99-
page_md_content = page_md_file.read()
100-
page_md_content = page_md_content.replace("Page example", page_name.replace("_", " ").title())
101-
with open(os.path.join(os.getcwd(), "pages", page_name, page_name + ".md"), "w") as page_md_file:
102-
page_md_file.write(page_md_content)
10398

10499
with open(os.path.join(os.getcwd(), "pages", "page_example", "page_example.py"), "r") as page_content_file:
105100
page_py_content = page_content_file.read()
106101
page_py_content = page_py_content.replace("page_example", page_name)
102+
page_py_content = page_py_content.replace("Page example", page_name.replace("_", " ").title())
107103
with open(os.path.join(os.getcwd(), "pages", page_name, page_name + ".py"), "w") as page_content_file:
108104
page_content_file.write(page_py_content)
109105

taipy/templates/default/{{cookiecutter.__root_folder}}/pages/page_example/page_example.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

taipy/templates/default/{{cookiecutter.__root_folder}}/pages/page_example/page_example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
"""
1313
A page of the application.
14-
Page content is imported from the page_example.md file.
14+
Page content is built using the Page builder API.
1515
16-
Please refer to https://docs.taipy.io/en/latest/manuals/userman/gui/pages for more details.
16+
Please refer to https://docs.taipy.io/en/latest/userman/gui/pages/builder/ for more details.
1717
"""
1818

19-
from taipy.gui import Markdown
19+
import taipy.gui.builder as tgb
2020

21-
page_example = Markdown("pages/page_example/page_example.md")
21+
with tgb.Page() as page_example:
22+
tgb.text("# Page example", mode="md")

taipy/templates/default/{{cookiecutter.__root_folder}}/pages/root.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

taipy/templates/default/{{cookiecutter.__root_folder}}/pages/root.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
"""
1313
The root page of the application.
14-
Page content is imported from the root.md file.
14+
Page content is built using the Page builder API.
1515
16-
Please refer to https://docs.taipy.io/en/latest/manuals/userman/gui/pages for more details.
16+
Please refer to https://docs.taipy.io/en/latest/userman/gui/pages/builder/ for more details.
1717
"""
1818

19-
from taipy.gui import Markdown
19+
import taipy.gui.builder as tgb
2020

21-
root_page = Markdown("pages/root.md")
21+
with tgb.Page() as root_page:
22+
tgb.navbar()

taipy/templates/sdm/{{cookiecutter.__root_folder}}/pages/job_page/job_page.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

taipy/templates/sdm/{{cookiecutter.__root_folder}}/pages/job_page/job_page.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
1010
# specific language governing permissions and limitations under the License.
1111

12-
from taipy.gui import Markdown
12+
import taipy.gui.builder as tgb
1313

14-
job_page = Markdown("pages/job_page/job_page.md")
14+
with tgb.Page() as job_page:
15+
tgb.job_selector()

taipy/templates/sdm/{{cookiecutter.__root_folder}}/pages/root.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

taipy/templates/sdm/{{cookiecutter.__root_folder}}/pages/root.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@
99
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
1010
# specific language governing permissions and limitations under the License.
1111

12-
from taipy.gui import Markdown
12+
import taipy.gui.builder as tgb
1313

1414
selected_scenario = None
1515
selected_data_node = None
1616
content = ""
1717

18-
root = Markdown("pages/root.md")
18+
19+
with tgb.Page() as root:
20+
with tgb.layout(columns="1, 5"):
21+
with tgb.part(class_name="sidebar"):
22+
tgb.scenario_selector("{selected_scenario}")
23+
24+
with tgb.part(render="{selected_scenario}"):
25+
tgb.data_node_selector("{selected_data_node}", display_cycles=False)
26+
27+
with tgb.part(class_name="main"):
28+
tgb.navbar()
29+
30+
with tgb.part(class_name="main"):
31+
tgb.text("{content}")

taipy/templates/sdm/{{cookiecutter.__root_folder}}/pages/scenario_page/scenario_page.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)