mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Template dev tools: Print the type of the response and stringify objects (#7439)
This commit is contained in:
parent
9fbc94e8d8
commit
174f8f5823
@ -82,6 +82,13 @@ class HaPanelDevTemplate extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
|
const type = typeof this._templateResult?.result;
|
||||||
|
const resultType =
|
||||||
|
type === "object"
|
||||||
|
? Array.isArray(this._templateResult?.result)
|
||||||
|
? "list"
|
||||||
|
: "dict"
|
||||||
|
: type;
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class="content ${classMap({
|
class="content ${classMap({
|
||||||
@ -141,16 +148,28 @@ class HaPanelDevTemplate extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="render-pane">
|
<div class="render-pane">
|
||||||
<ha-circular-progress
|
${this._rendering
|
||||||
|
? html`<ha-circular-progress
|
||||||
class="render-spinner"
|
class="render-spinner"
|
||||||
.active=${this._rendering}
|
active
|
||||||
size="small"
|
size="small"
|
||||||
></ha-circular-progress>
|
></ha-circular-progress>`
|
||||||
|
: ""}
|
||||||
|
${this._templateResult
|
||||||
|
? html`${this.hass.localize(
|
||||||
|
"ui.panel.developer-tools.tabs.templates.result_type"
|
||||||
|
)}:
|
||||||
|
${resultType}`
|
||||||
|
: ""}
|
||||||
|
<!-- prettier-ignore -->
|
||||||
<pre
|
<pre
|
||||||
class="rendered ${classMap({ error: Boolean(this._error) })}"
|
class="rendered ${classMap({
|
||||||
><!-- display: block -->${this._error}${this._templateResult
|
error: Boolean(this._error),
|
||||||
?.result}</pre>
|
[resultType]: resultType,
|
||||||
|
})}"
|
||||||
|
>${this._error}${type === "object"
|
||||||
|
? JSON.stringify(this._templateResult!.result, null, 2)
|
||||||
|
: this._templateResult?.result}</pre>
|
||||||
${this._templateResult?.listeners.time
|
${this._templateResult?.listeners.time
|
||||||
? html`
|
? html`
|
||||||
<p>
|
<p>
|
||||||
|
@ -2957,6 +2957,7 @@
|
|||||||
"description": "Templates are rendered using the Jinja2 template engine with some Home Assistant specific extensions.",
|
"description": "Templates are rendered using the Jinja2 template engine with some Home Assistant specific extensions.",
|
||||||
"editor": "Template editor",
|
"editor": "Template editor",
|
||||||
"reset": "Reset to demo template",
|
"reset": "Reset to demo template",
|
||||||
|
"result_type": "Result type",
|
||||||
"jinja_documentation": "Jinja2 template documentation",
|
"jinja_documentation": "Jinja2 template documentation",
|
||||||
"template_extensions": "Home Assistant template extensions",
|
"template_extensions": "Home Assistant template extensions",
|
||||||
"unknown_error_template": "Unknown error rendering template",
|
"unknown_error_template": "Unknown error rendering template",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user