Skip to content

Commit 9a0b944

Browse files
committed
smarter tooltip generation, better escaping
1 parent 4ba443b commit 9a0b944

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

app/blocks/text/template.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default {
66
colour: 180,
77
inputsInline: true,
88
description: `
9+
::: v-pre
910
Create dynamic, personalized messages by combining static text with live data from your IoT system. Perfect for intelligent notifications like "Hello {{ user.name }}, your temperature sensor read {{ feeds['sensors.temperature'].value }}°F" or automated reports that include current sensor values, user information, and real-time data. Uses the powerful Liquid templating language for advanced formatting and logic.
1011
1112
## What is a Text Template?
@@ -15,7 +16,6 @@ export default {
1516
## How It Works
1617
1718
This block renders (processes) a text template, replacing special placeholders with actual values.
18-
::: v-pre
1919
Anything surrounded by {{ double curly braces }} gets replaced with real data when your action runs.
2020
2121
For example:
@@ -177,7 +177,17 @@ export default {
177177
template: "{{ %TEMPLATE",
178178
inputs: {
179179
TEMPLATE: {
180-
description: "Create your template text with static content and dynamic {{ variable }} placeholders. Examples: 'Alert: {{ feeds['temp.kitchen'].value }}°F detected' or 'Daily Report for {{ user.name }}: Battery at {{ vars.battery_level }}%'. Use {{ }} to insert live data into your message.",
180+
description: `
181+
::: v-pre
182+
Create your template text with static content and dynamic {{ variable }} placeholders.
183+
184+
Examples:
185+
- 'Alert: {{ feeds['temp.kitchen'].value }}°F detected'
186+
- 'Daily Report for {{ user.name }}: Battery at {{ vars.battery_level }}%'
187+
188+
Use {{ }} to insert live data into your message.
189+
:::
190+
`,
181191
check: "expression",
182192
shadow: 'io_text_multiline'
183193
}

src/definitions/block_definition.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ BlockDefinition.parseRawDefinition = function(rawBlockDefinition, definitionPath
191191
? niceTemplate(rawBlockDefinition.description)
192192
: ""
193193
blockDef.ioPlus = rawBlockDefinition.ioPlus
194-
blockDef.tooltip = blockDef.description.split("\n")[0]
194+
// take the first line of the description
195+
// blockDef.tooltip = blockDef.description.split("\n")[0]
196+
// take the first sentence of the description
197+
blockDef.tooltip = blockDef.description.split(/\.(\s|$)/)[0] + "."
195198
blockDef.disabled = !!rawBlockDefinition.disabled
196199
blockDef.connections = rawBlockDefinition.connections
197200
blockDef.template = rawBlockDefinition.template

src/docs/render_block_inputs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const
3636
if(input.type === 'label') { return }
3737

3838
lines.push(`### \`${ capitalize(inputName) }\``)
39-
lines.push(input.description)
39+
if(input.description) { lines.push(niceTemplate(input.description)) }
4040
})
4141

4242
return lines.join("\n\n")

0 commit comments

Comments
 (0)