Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-detect language in append_shinylive_chunk() #161

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def append_file(self, file_path: str, file_name: Optional[str] = None):
def append_shinylive_chunk(
self,
files: list[str] | str,
language: str = "py",
language: Literal["auto", "py", "r"] = "auto",
**kwargs,
):
if isinstance(files, str):
Expand All @@ -32,6 +32,9 @@ def append_shinylive_chunk(
else:
app_file = files.pop(0)

if language == "auto":
language = "py" if app_file.endswith(".py") else "r"

app = ShinyliveApp.from_local(app_file, files, language)

self.append(app.to_chunk(**kwargs))
Expand Down
Loading