Skip to content

Commit 8d45c26

Browse files
authored
Add shiny create option to choose from online template gallery (#1277)
1 parent 784c12a commit 8d45c26

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

shiny/_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ def try_import_module(module: str) -> Optional[types.ModuleType]:
483483
"Dashboard": "dashboard",
484484
"Multi-page app with modules": "multi-page",
485485
"Custom JavaScript Component": "js-component",
486+
"Choose from the Shiny Templates website": "external-gallery",
486487
}
487488

488489
# These are templates which produce a Python package and have content filled in at

shiny/_template_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ def template_query(
7373
# Define the control flow for the top level menu
7474
if template is None or template == "cancel":
7575
sys.exit(1)
76+
elif template == "external-gallery":
77+
url = "https://shiny.posit.co/py/templates"
78+
print(f"Opening <{url}> in your browser.")
79+
print("Choose a template and copy the `shiny create` command to use it.")
80+
import webbrowser
81+
82+
webbrowser.open(url)
83+
sys.exit(0)
7684
elif template == "js-component":
7785
js_component_questions(dest_dir=dest_dir, package_name=package_name)
7886
return

0 commit comments

Comments
 (0)