8000 Prepending panel to Template does not work. · Issue #1736 · holoviz/panel · GitHub
[go: up one dir, main page]

Skip to content

Prepending panel to Template does not work. #1736

@MarcSkovMadsen

Description

@MarcSkovMadsen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0