[Design]Jinja2 support in Markup Viz
See original GitHub issueMake sure these boxes are checked before submitting your issue - thank you!
- I have checked the superset logs for python stacktraces and included it here as text if there are any.
- I have reproduced the issue with at least the latest released version of superset.
- I have checked the issue tracker for the same issue and I haven’t found one similar.
Superset version
0.28.1
Expected results
Jinja2 Templating in Markup Viz
Actual results
Steps to reproduce
def query_obj(self):
return None
def get_df(self, query_obj=None):
return None
def get_data(self, df):
markup_type = self.form_data.get('markup_type')
code = self.form_data.get('code', '')
if markup_type == 'markdown':
code = markdown(code)
return dict(html=code, theme_css=get_css_manifest_files('theme'))
else:
print(template_processor.context["current_username"]())
return dict(
html=jinja2.Environment().from_string(code).render(template_processor=template_processor),
theme_css=get_css_manifest_files('theme')
)`
The question here is, how safe is this? template_processor is object of jinja_context.BaseTemplateProcessor
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
apache/superset - [Design]Jinja2 support in Markup Viz - GitHub
[Design]Jinja2 support in Markup Viz #6771 ... class MarkupViz(BaseViz): """Use html or markdown to create a free form widget""" viz_type = "markup" ...
Read more >[GitHub] [incubator-superset] gbrian commented ... - The Mail Archive
gbrian commented on issue #6771: [Design]Jinja2 support in Markup Viz URL: https://github.com/apache/incubator-superset/issues/6771#issuecomment-511355378 ...
Read more >Jinja Documentation (3.0.x) » Template Designer ...
The context dictionary by the application with markupsafe.Markup. The template, with the |safe filter. If a string that you marked safe is ...
Read more >Understanding Jinja - Salt Project Documentation
Jinja supports a secure, sandboxed template execution environment that Salt takes ... as useful (viz. you likely want to use yaml_encode or yaml_dquote...
Read more >How to use the jinja2.utils.Markup function in Jinja2 - Snyk
To help you get started, we've selected a few jinja2.utils.Markup examples, based on popular ways it is used in public projects.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @mistercrunch this viz will be quite good for our project. It will give us lot of possibilities to create a rich Welcome dashboards for the user. It will be great if we can use Jinja2 templates and query a datasource.
Using Jinja2 templates:
In my case I’m using existing
BaseTemplateProcessor
from superset.jinja_context import get_template_processor
Let me know if this is something good/NTH in order to create a PR.
Thanks to your advices I was able to enable templating in markup chart. Thanks!