marimo icon indicating copy to clipboard operation
marimo copied to clipboard

feat: _display_ protocol

Open akshayka opened this issue 1 year ago • 2 comments

If an object implements _display_() -> Any, we render it using marimo's built-in renderer applied to obj._display_().

Example:

image

akshayka avatar Oct 02 '24 04:10 akshayka

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 10:12pm
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 10:12pm

vercel[bot] avatar Oct 02 '24 04:10 vercel[bot]

Is this a documented protocol? Should we include it in our documentation and write a test

mscolnick avatar Oct 02 '24 11:10 mscolnick

May revisit later ...

akshayka avatar Oct 08 '24 22:10 akshayka

I found a good reason for this. These are equivalent, so I don't think it is worth the syntactic sugar, but having _display_ could benefit libraries that don't/can't depend on marimo

def _display_():
  return obj

def _mime_():
  return ("text/html", mo.as_html(obj))

mscolnick avatar Nov 16 '24 00:11 mscolnick

Docs?

mscolnick avatar Nov 18 '24 00:11 mscolnick

Yea needs docs and tests. Will finish this up later this week

akshayka avatar Nov 18 '24 02:11 akshayka

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.9.21-dev8

github-actions[bot] avatar Nov 19 '24 22:11 github-actions[bot]