Is there a way to get a “callings cell”'s name?
I am looking for a keyword or variable that will resolve to the name of the cell that a function is being called from:
Age = slider({ value: 10, min: 0, max: 120 }) // Slider can now show `"Age"` as title
slider = ({
title = CELL_NAME, // or `import.meta.cell_name` or something
...options,
}) => {
// Render slider with `title`
}
It seems like this is not yet possible. I do get why, as it is quite tricky (if not impossible) to make it work reliable. I think it would make experimenting with different inputs a lot easier, however. I now use a custom stylesheet to show a cells name to the left, because I just want to do Age = slider({ value: 10, min: 0, max: 120 })
and not have to worry about showing the title.
Also it is useful for the sub-notebooks I’m using now, as repeating the cell name with room for error feels wasteful (Example: Sub-notebook example: Debate Round Scheduler / Matcher / Michiel Dral / Observable)
I made some examples for how to carry the name through functions calls using the Error stack, though this requires wrapping it explicitly, which is obviously even worse when not integrated into Observable:
Is there a way I am missing that is currently available, or something more fundamental that makes it incompatible? Would love to see what comes up