html_url,issue_url,id,node_id,user,user_label,created_at,updated_at,author_association,body,reactions,issue,issue_label,performed_via_github_app https://github.com/simonw/datasette/issues/577#issuecomment-568276310,https://api.github.com/repos/simonw/datasette/issues/577,568276310,MDEyOklzc3VlQ29tbWVudDU2ODI3NjMxMA==,9599,simonw,2019-12-22T16:10:31Z,2019-12-22T16:10:31Z,OWNER,"The code in question currently lives in `BaseView.render()`: https://github.com/simonw/datasette/blob/d54318fc7f2565e6121920ce1ea9cb8b700e629a/datasette/views/base.py#L106-L163 Should `datasette.render_template()` do exactly this, or should it be slightly different? Plugins need the option to not pass a `request` object - so maybe that parameter becomes optional. Perhaps plugins should be able to render templates without other plugins getting to inject their own variables? Does it always make sense to dump in all of those extra template context variables?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",497171390,Utility mechanism for plugins to render templates, https://github.com/simonw/datasette/issues/651#issuecomment-568268746,https://api.github.com/repos/simonw/datasette/issues/651,568268746,MDEyOklzc3VlQ29tbWVudDU2ODI2ODc0Ng==,9599,simonw,2019-12-22T14:37:37Z,2019-12-22T14:37:37Z,OWNER,"I've not yet been able to figure out what the escaping rule are for FTS5 queries. If we figure out how those work maybe we can bundle them as a custom function? select ... where docs_fts match fts_escape(:search) ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",539590148,fts5 syntax error when using punctuation, https://github.com/simonw/datasette/issues/651#issuecomment-568269476,https://api.github.com/repos/simonw/datasette/issues/651,568269476,MDEyOklzc3VlQ29tbWVudDU2ODI2OTQ3Ng==,9599,simonw,2019-12-22T14:46:37Z,2019-12-22T14:47:03Z,OWNER,"https://stackoverflow.com/a/43756146 says that an escaping mechanism that works is this one: select * from blah where term match '""bacon"" ""and"" ""eggs""' So split on whitespace and then encapsulate each search term in double quotes.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",539590148,fts5 syntax error when using punctuation, https://github.com/simonw/datasette/issues/654#issuecomment-568274520,https://api.github.com/repos/simonw/datasette/issues/654,568274520,MDEyOklzc3VlQ29tbWVudDU2ODI3NDUyMA==,9599,simonw,2019-12-22T15:51:58Z,2019-12-22T15:51:58Z,OWNER,"Proof of concept: ```diff diff --git a/datasette/views/base.py b/datasette/views/base.py index 5182479..39d1f77 100644 --- a/datasette/views/base.py +++ b/datasette/views/base.py @@ -1,6 +1,7 @@ import asyncio import csv import itertools +import json import re import time import urllib @@ -138,28 +139,31 @@ class BaseView(AsgiView): ) extra_template_vars.update(extra_vars) + template_context = { + **context, + **{ + ""app_css_hash"": self.ds.app_css_hash(), + ""select_templates"": select_templates, + ""zip"": zip, + ""body_scripts"": body_scripts, + ""extra_css_urls"": self._asset_urls( + ""extra_css_urls"", template, context + ), + ""extra_js_urls"": self._asset_urls( + ""extra_js_urls"", template, context + ), + ""format_bytes"": format_bytes, + ""database_url"": self.database_url, + ""database_color"": self.database_color, + }, + **extra_template_vars, + } + if request.args.get(""_context""): + return Response.html(""
{}
"".format( + escape(json.dumps(template_context, default=repr, indent=4)) + )) return Response.html( - await template.render_async( - { - **context, - **{ - ""app_css_hash"": self.ds.app_css_hash(), - ""select_templates"": select_templates, - ""zip"": zip, - ""body_scripts"": body_scripts, - ""extra_css_urls"": self._asset_urls( - ""extra_css_urls"", template, context - ), - ""extra_js_urls"": self._asset_urls( - ""extra_js_urls"", template, context - ), - ""format_bytes"": format_bytes, - ""database_url"": self.database_url, - ""database_color"": self.database_color, - }, - **extra_template_vars, - } - ) + await template.render_async(template_context) ) ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",541467590,Template debug mode that outputs template context, https://github.com/simonw/datasette/issues/654#issuecomment-568274570,https://api.github.com/repos/simonw/datasette/issues/654,568274570,MDEyOklzc3VlQ29tbWVudDU2ODI3NDU3MA==,9599,simonw,2019-12-22T15:52:43Z,2019-12-22T15:52:43Z,OWNER,"One problem with this: what if secrets end up being dumped out in this debug view? This won't happen with default Datasette but could potentially happen with a plugin. This feature should be opt-in - maybe a `template_debug:1` config setting.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",541467590,Template debug mode that outputs template context, https://github.com/simonw/datasette/issues/654#issuecomment-568276548,https://api.github.com/repos/simonw/datasette/issues/654,568276548,MDEyOklzc3VlQ29tbWVudDU2ODI3NjU0OA==,9599,simonw,2019-12-22T16:13:11Z,2019-12-22T16:13:11Z,OWNER,"Documentation: https://datasette.readthedocs.io/en/latest/config.html#template-debug Demos: * https://latest.datasette.io/?_context=1 * https://latest.datasette.io/fixtures?_context=1 * https://latest.datasette.io/fixtures/roadside_attractions?_context=1 ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",541467590,Template debug mode that outputs template context,