{"html_url": "https://github.com/simonw/datasette/pull/1069#issuecomment-719640430", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1069", "id": 719640430, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTY0MDQzMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-30T16:01:13Z", "updated_at": "2020-10-30T16:01:13Z", "author_association": "OWNER", "body": "Next steps: build a demonstration plugin against this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 733303548, "label": "load_template() plugin hook"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1069#issuecomment-719657478", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1069", "id": 719657478, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTY1NzQ3OA==", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2020-10-30T16:31:21Z", "updated_at": "2020-10-30T17:46:36Z", "author_association": "NONE", "body": "# [Codecov](https://codecov.io/gh/simonw/datasette/pull/1069?src=pr&el=h1) Report\n> Merging [#1069](https://codecov.io/gh/simonw/datasette/pull/1069?src=pr&el=desc) into [main](https://codecov.io/gh/simonw/datasette/commit/222f79bb4c6e2aa5426cc5ff25f1b2461e18a300?el=desc) will **increase** coverage by `0.01%`.\n> The diff coverage is `95.83%`.\n\n[![Impacted file tree graph](https://codecov.io/gh/simonw/datasette/pull/1069/graphs/tree.svg?width=650&height=150&src=pr&token=eSahVY7kw1)](https://codecov.io/gh/simonw/datasette/pull/1069?src=pr&el=tree)\n\n```diff\n@@ Coverage Diff @@\n## main #1069 +/- ##\n==========================================\n+ Coverage 91.30% 91.32% +0.01% \n==========================================\n Files 29 29 \n Lines 3736 3756 +20 \n==========================================\n+ Hits 3411 3430 +19 \n- Misses 325 326 +1 \n```\n\n\n| [Impacted Files](https://codecov.io/gh/simonw/datasette/pull/1069?src=pr&el=tree) | Coverage \u0394 | |\n|---|---|---|\n| [datasette/views/base.py](https://codecov.io/gh/simonw/datasette/pull/1069/diff?src=pr&el=tree#diff-ZGF0YXNldHRlL3ZpZXdzL2Jhc2UucHk=) | `93.94% <\u00f8> (-0.04%)` | :arrow_down: |\n| [datasette/app.py](https://codecov.io/gh/simonw/datasette/pull/1069/diff?src=pr&el=tree#diff-ZGF0YXNldHRlL2FwcC5weQ==) | `96.38% <95.45%> (-0.05%)` | :arrow_down: |\n| [datasette/hookspecs.py](https://codecov.io/gh/simonw/datasette/pull/1069/diff?src=pr&el=tree#diff-ZGF0YXNldHRlL2hvb2tzcGVjcy5weQ==) | `100.00% <100.00%> (\u00f8)` | |\n\n------\n\n[Continue to review full report at Codecov](https://codecov.io/gh/simonw/datasette/pull/1069?src=pr&el=continue).\n> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)\n> `\u0394 = absolute (impact)`, `\u00f8 = not affected`, `? = missing data`\n> Powered by [Codecov](https://codecov.io/gh/simonw/datasette/pull/1069?src=pr&el=footer). Last update [222f79b...92f3840](https://codecov.io/gh/simonw/datasette/pull/1069?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 733303548, "label": "load_template() plugin hook"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1069#issuecomment-719664530", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1069", "id": 719664530, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTY2NDUzMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-30T16:43:40Z", "updated_at": "2020-10-30T16:43:40Z", "author_association": "OWNER", "body": "I should include an example in the documentation that shows loading templates from a database table.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 733303548, "label": "load_template() plugin hook"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1069#issuecomment-719666912", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1069", "id": 719666912, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTY2NjkxMg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-30T16:47:44Z", "updated_at": "2020-10-30T16:47:44Z", "author_association": "OWNER", "body": "Bringing over a comment from #1042:\r\n\r\n> I'd like to do this all in the `datasette.render_template()` method to ensure it's available to plugins as well, not just core code that uses the `BaseView` class.\r\n> \r\n> This code is the problem:\r\n> \r\n> https://github.com/simonw/datasette/blob/d3e9b0aecb6f8e9b2befd9c654ccb7ce852db3e7/datasette/views/base.py#L114-L133\r\n> \r\n> I think I'll fix this by moving the `select_templates` mechanism into `datasette.render_templates()`.\r\n\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 733303548, "label": "load_template() plugin hook"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1069#issuecomment-719670714", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1069", "id": 719670714, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTY3MDcxNA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-30T16:53:56Z", "updated_at": "2020-10-30T16:53:56Z", "author_association": "OWNER", "body": "I'm having second thoughts about the design of the plugin hook.\r\n\r\nConsider the following:\r\n```python\r\n plugin_template_source = pm.hook.load_template(\r\n template=template_name,\r\n database=context.get(\"database\"),\r\n table=context.get(\"table\"),\r\n columns=context.get(\"columns\"),\r\n view_name=self.name,\r\n request=request,\r\n datasette=self.ds,\r\n )\r\n```\r\nIt's a bit gross that `database`, `table` and `columns` are pulled out of the context like that. This doesn't make sense for pages that are rendered by plugins, for example.\r\n\r\nSo maybe for the first release of this plugin hook I should cut it down to just seeing `template`, `request` and `datasette`. I can add the table/view/etc stuff back in later if it turns out to be necessary.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 733303548, "label": "load_template() plugin hook"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1069#issuecomment-719672967", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1069", "id": 719672967, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTY3Mjk2Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-30T16:58:01Z", "updated_at": "2020-10-30T16:58:01Z", "author_association": "OWNER", "body": "OK, new hook specification is:\r\n```python\r\n@hookspec(firstresult=True)\r\ndef load_template(template, request, datasette):\r\n \"Load the specified template, returning the template code as a string\"\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 733303548, "label": "load_template() plugin hook"}, "performed_via_github_app": null}