improve fn node

This commit is contained in:
2026-03-08 11:19:51 +01:00
parent 48a6917a81
commit 2407470c14
6 changed files with 148 additions and 61 deletions

View File

@@ -57,7 +57,11 @@ const DEFAULT_DATA: Record<string, any> = {
config: { plantuml: '@startuml\n\n@enduml\n', title: '' },
render: {},
variable: { value: '', valueType: 'string' },
function: { body: '// args[0], args[1], ...\nreturn args[0];' },
function: {
body: `function(num, kwargs) {
return num + (kwargs.bar || 0);
}`,
},
}
export function getDefaultDataForType(type: string, newId?: string): any {

View File

@@ -61,7 +61,7 @@ export function nunjucksCompletionSource(
}
for (const id of functionIds ?? []) {
if (!word || id.toLowerCase().startsWith(word.toLowerCase())) {
options.push({ label: id, type: 'function', info: 'Function (e.g. ' + id + '(var, 4))' })
options.push({ label: id, type: 'function', info: "Filter: {{ '' | " + id + " }}" })
}
}
for (const kw of NUNJUCKS_KEYWORDS) {