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
Add RenderSnippet to Renderer to facilitate their embedding within other templates #410
base: master
Are you sure you want to change the base?
Conversation
…_script, and base_scripts
… it in chartRender & pageRender
HI @sdqri thx for ur great idea and contributions! |
I'm collaborating on this gonb issue -- the goal is to have Echarts within Golang Jupyter notebooks, both in browser and VSCode. I think this feature will be helpful for that effort. |
Hi @sdqri , I checked this PR and ran the sample you provided. It works fine to output escape snippets (maybe we need a config that enable escape content or not? ). When I try to render in page, the TBH, I hasn't decide that where to put this feature in. Currently, I'm thinking about the two options:
Any thoughts on this plz let me know :). |
hi, In the meantime I created a small library to integrate It's working great 😃 See examples page, it is the HTML export of a working Jupyter notebook. Btw, would it be ok to add an entry in the Features section of the |
Apologies for the delay in responding and thanks for the review. I totally understand your concern regarding the integration of this feature into the Render interface. I must admit that, since I'm not entirely familiar with the project's structure and scope, I may lack sufficient knowledge to decide which of these options are better for project. Personally, I opted to use a custom renderer in my use case. However, since I believed this feature would be beneficial to a significant portion of the library's users, my attempt in the pull request was to implement it as simply as possible, with minimal changes to the project structure. Unfortunately, since the renderer abstracts both component and page into one bucket, any implementation that wants to change this will lead to some unintended overloading of pageRender, with a potentially redundant method, and it also will break backward compatibility of the Render interface. Nevertheless, I still strongly support the integration of such a feature directly into the library, and I'll be happy to contribute to make this possible. |
That's a great job! and of course, for now I will add it as the |
Hi @sdqri , thx for your thoughts. and I agree what you mentioned is reasonable. I will do the rest of things (sorry that may not be that quick since I don't have much time on it recently):
|
Description
Recently I was using go-echarts in one of my projects and I would have liked it if It was possible to embed my charts into custom templates, but I couldn't find a straightforward way to achieve this. I found this article that talks about the same problem with go-echarts and solves it by implementing a custom renderer. I find it strange that there isn't a built-in way to do this, considering that embedding charts instead of firing a standalone HTTP page or using iframes is expected by most users in production.
I have a simple implementation to do this by adding a RenderSnippet function to the Renderer interface, which is a charm when working only with charts. But the only problem is that both pageRender & chartRender use the same Renderer interface and defining the correct behavior for this method in PageRender can be a little tricky. I've solved it by collecting all elements & scripts in singular fields.
Type of change
Example