Skip to content

Installation

YAPL is available as a TypeScript/JavaScript library that can be used in both Node.js and browser environments, while the latter not makes much sense for most people.

  • Node.js 18 or higher
  • npm, yarn, or pnpm

Install YAPL using your preferred package manager:

Terminal window
# npm
npm install @yapl-language/yapl.ts
# yarn
yarn add @yapl-language/yapl.ts
# pnpm
pnpm add @yapl-language/yapl.ts

For Node.js applications with file system access:

import { NodeYAPL } from "@yapl-language/yapl.ts";
const yapl = new NodeYAPL({
baseDir: "./prompts", // Directory containing your .yapl files
});
// Render a template file and pass your variables.
const result = await yapl.render("agent.md.yapl", {
variable1: "Assistant",
variable2: "customer support",
});
console.log(result.content);

For browser applications or when you don’t need file system access:

import { YAPL } from "@yapl-language/yapl.ts";
const yapl = new YAPL({
baseDir: "/virtual", // Virtual base directory, is necessary to tell YAPL it's running in a Browser environment.
});
// Render template strings directly
const templateSource = `
Hello, {{ name | default("World") }}!
{% if greeting %}{{ greeting }}{% endif %}
`;
const result = await yapl.renderString(templateSource, {
name: "YAPL User",
greeting: "Welcome to YAPL!",
});
console.log(result.content);
OptionTypeDefaultDescription
baseDirstringRequiredBase directory for template files
cachebooleantrueEnable file caching (Node.js only)
strictPathsbooleantruePrevent path traversal outside baseDir
maxDepthnumber20Maximum template nesting depth
whitespaceWhitespaceOptionsSee belowWhitespace control options
OptionTypeDefaultDescription
trimBlocksbooleantrueRemove newlines after block tags
lstripBlocksbooleantrueRemove leading whitespace before block tags
dedentBlocksbooleantrueRemove common indentation from block content

Organize your YAPL templates in a clear directory structure like this for example, but you can use any structure you like:

prompts/
├── base/
│ ├── system.md.yapl
│ └── agent.md.yapl
├── mixins/
│ ├── friendly.md.yapl
│ ├── professional.md.yapl
│ └── safety.md.yapl
├── agents/
│ ├── customer-support.md.yapl
│ ├── technical-writer.md.yapl
│ └── code-reviewer.md.yapl
└── tasks/
├── summarize.md.yapl
├── translate.md.yapl
└── analyze.md.yapl

YAPL templates can be written in many formats:

  • .yapl - Pure YAPL templates
  • .md.yapl - Markdown-based prompts with YAPL templating
  • .txt.yapl - Plain text prompts with YAPL templating
  • .json.yapl - JSON-structured prompts with YAPL templating

For the best development experience, install the official YAPL VS Code extension:

Install VS Code Extension

For VSCodium and other Open VSX compatible editors:

Install Open VSX Extension

The extension provides:

  • Syntax highlighting for .yapl files
  • Snippets for common YAPL constructs
  • IntelliSense support for YAPL syntax

Now that you have YAPL installed, check out the Quick Start guide to learn the basics, or dive into the Core Features documentation to explore YAPL’s capabilities.