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

Prepending panel to Template does not work. #1736

Closed
MarcSkovMadsen opened this issue Nov 2, 2020 · 0 comments · Fixed by #1737
Closed

Prepending panel to Template does not work. #1736

MarcSkovMadsen opened this issue Nov 2, 2020 · 0 comments · Fixed by #1737
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Nov 2, 2020

ALL software version info

Panel 0.10.1

Description of expected behavior and the observed behavior

When main of a Template is a List I would expect to be able to prepend items to the list.

I need this functionality to enable a work flow where every application in our site automatically gets wrapped with a generic header (=Card with title, info and links). So we would develop our application via a Template and fill in main. But then we would prepend the info header automatically

image

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn

def _create_app():
    view = pn.pane.Markdown("App View")
    app=pn.template.MaterialTemplate()
    app.main[:]=[view] # There might be a list of elements

    # Something done automatically for all apps in the site
    info_card = pn.pane.Markdown("Info Card")
    app.main.insert(0, info_card)
    return app

def test_app():
    app = _create_app()
    main_items = [item[0] for item in app._render_items.values() if "main" in item[1]]

    assert main_items[0].object=="Info Card"
    assert main_items[1].object=="App View"

if __name__.startswith("bokeh"):
    _create_app().servable()

Screenshots or screencasts of the bug in action

python -m panel serve 'scripts\issue_render_items.py' --dev

image

`pytest 'scripts\issue_render_items.py'

$ pytest 'scripts\issue_render_items.py'
Test session starts (platform: win32, Python 3.7.6, pytest 5.4.2, pytest-sugar 0.9.3)
rootdir: C:\repos\private\awesome-panel, inifile: pytest.ini
plugins: cov-2.8.1, mock-3.1.0, sugar-0.9.3
collecting ... 

――――――――――――――――――――――――――――――――――――――― test_app ―――――――――――――――――――――――――――――――――――――――

    def test_app():
        app = _create_app()
        main_items = [item[0] for item in app._render_items.values() if "main" in item[1]]

>       assert main_items[0].object=="Info Card"
E       AssertionError: assert 'App View' == 'Info Card'
E         - Info Card
E         + App View

scripts\issue_render_items.py:17: AssertionError

 scripts/issue_render_items.py ⨯                                          100% ██████████
=============================== short test summary info ================================
FAILED scripts/issue_render_items.py::test_app - AssertionError: assert 'App View' == ...

Results (1.47s):
       1 failed
         - scripts/issue_render_items.py:13 test_app
@MarcSkovMadsen MarcSkovMadsen added the TRIAGE Default label for untriaged issues label Nov 2, 2020
@MarcSkovMadsen MarcSkovMadsen changed the title Prepending panel to main of Template does not work. Prepending panel to Template does not work. Nov 2, 2020
@philippjfr philippjfr added type: bug Something isn't correct or isn't working and removed TRIAGE Default label for untriaged issues labels Nov 2, 2020
@philippjfr philippjfr added this to the v0.10.2 milestone Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants