More template functions

This commit is contained in:
Gregory Schier
2025-05-25 20:27:04 -07:00
parent d02883282f
commit 6d6012fe67
10 changed files with 207 additions and 26 deletions

View File

@@ -0,0 +1,22 @@
import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
export const plugin: PluginDefinition = {
templateFunctions: [
{
name: 'base64.encode',
description: 'Encode a value to base64',
args: [{ label: 'Plain Text', type: 'text', name: 'value', multiLine: true }],
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
return Buffer.from(args.values.value ?? '').toString('base64');
},
},
{
name: 'base64.decode',
description: 'Decode a value from base64',
args: [{ label: 'Encoded Value', type: 'text', name: 'value', multiLine: true }],
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
return Buffer.from(args.values.value ?? '', 'base64').toString('utf-8');
},
},
],
};