Skip to content

@render.download in Express modules #1856

@julibeg

Description

@julibeg

Related to #1724 and #1726 but in Express.

@express.render.download() doesn't accept an id argument and also doesn't include the parent module's ns in the download link. Therefore, all download buttons created with an Express module download the same file. Consider the MWE below

from shiny.express import module, render, ui


@module
def card_with_download(input, output, session, label):
    with ui.card():
        ui.card_header(f"download {label}")

        @render.download(filename=f"test-{label}.txt", label=f"Download {label}")
        def download():
            yield f"Hi, we're in {label} file\n"


labels = list("ABCD")

for i, label in enumerate(labels):
    card_with_download(f"download_{label}", label=label)

Each of the buttons will download test-D.txt.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions