Add more template tag plugins (#3)

This commit is contained in:
Gregory Schier
2024-10-02 06:56:07 -07:00
committed by GitHub
parent 9df586cb59
commit 54689d19ef
29 changed files with 412 additions and 7160 deletions

View File

@@ -0,0 +1,18 @@
import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
import fs from 'node:fs';
export const plugin: PluginDefinition = {
templateFunctions: [{
name: 'fs.readFile',
args: [{ title: 'Select File', type: 'file', name: 'path', label: 'File' }],
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
if (!args.values.path) return null;
try {
return fs.promises.readFile(args.values.path, 'utf-8');
} catch (err) {
return null;
}
},
}],
};