Otter
Blueprints
Otter
Upstream Blueprint Tested
Text Sanitization and Slug Generator Blueprint
Clean raw user input into URL-safe slugs and padded identifier codes.
Architecture & Runtime Preview
Otter >=1.0.1Combines text-utils.slugify and text-utils.padLeft to produce normalized keys and formatted ID numbers.
- 1Raw Text Input (input)
- 2Slugify Text (pack-call: text-utils.slugify)
- 3Pad Left (pack-call: text-utils.padLeft)
- 4Sanitized Output (output)
Source Code (4 files)
{
"schemaVersion": 1,
"id": "otter-official/text-cleanup",
"version": "1.0.0",
"title": "Text Sanitization and Slug Generator",
"summary": "Clean raw user input into URL-safe slugs and padded identifier codes.",
"targets": ["console", "desktop", "web"],
"requiresOtter": ">=1.0.1",
"packs": [
{ "id": "otter-official/text-utils", "version": "1.0.1" }
],
"configuration": [
{
"id": "codeTargetLength",
"label": "Code Target Length",
"type": "number",
"default": 8,
"minimum": 2,
"description": "Total length for zero-padded identifier codes"
}
],
"nodes": [
{
"id": "rawInput",
"title": "Raw Text Input",
"kind": "input",
"inputs": [],
"outputs": [{ "name": "text", "type": "text" }],
"description": "Unformatted input title"
},
{
"id": "slugifyNode",
"title": "Slugify Text",
"kind": "pack-call",
"capability": "text-utils.slugify",
"inputs": [{ "name": "text", "type": "text", "required": true }],
"outputs": [{ "name": "slug", "type": "text" }],
"description": "Convert string to lowercase hyphenated format"
},
{
"id": "padNode",
"title": "Pad Left",
"kind": "pack-call",
"capability": "text-utils.padLeft",
"inputs": [
{ "name": "text", "type": "text", "required": true },
{ "name": "length", "type": "number", "required": true },
{ "name": "char", "type": "text", "required": true }
],
"outputs": [{ "name": "padded", "type": "text" }],
"description": "Prepend zero padding"
},
{
"id": "outputNode",
"title": "Sanitized Output",
"kind": "output",
"inputs": [
{ "name": "slug", "type": "text", "required": true },
{ "name": "code", "type": "text", "required": true }
],
"outputs": [],
"description": "Display generated slug and formatted code"
}
],
"edges": [
{ "from": "rawInput.text", "to": "slugifyNode.text", "label": "raw title" },
{ "from": "slugifyNode.slug", "to": "outputNode.slug", "label": "clean slug" },
{ "from": "padNode.padded", "to": "outputNode.code", "label": "padded code" }
],
"generatedFiles": [
{
"path": "src/cleanup.ot",
"template": "templates/cleanup.ot.tmpl"
}
],
"explanations": {
"beginner": "Converts titles into web-safe URL slugs (like 39;my-first-post39;) and formats invoice numbers with zeros.",
"intermediate": "Combines text-utils.slugify and text-utils.padLeft to produce normalized keys and formatted ID numbers.",
"advanced": "Standardized text normalization pipeline avoiding regex dependencies by using Otter core text operations."
},
"tests": [
"tests/test.ot"
]
}
# Generated by Otter Blueprint: otter-official/text-cleanup 1.0.0
# Standard editable Otter 1.0.1 source code
use "${import:otter-official/text-utils}"
rawTitle is "Otter Language 2026 Release"
itemId is "42"
targetLen is ${codeTargetLength}
# Step 1: Generate clean URL slug
cleanSlug is slugify rawTitle
# Step 2: Format numeric code
formattedCode is padLeft itemId targetLen "0"
say "Original Title:" rawTitle
say "URL Slug:" cleanSlug
say "Formatted Code: #" formattedCode
# Integration tests for text-cleanup Blueprint
use "../../../../packs/otter-official/text-utils/src/main.ot"
# Test 1: Slugify
s is slugify "Otter Programming Language"
if s is "otter-programming-language"
say "test 1 passed: slug generated correctly"
.
# Test 2: Pad left
p is padLeft "99" 5 "0"
if p is "00099"
say "test 2 passed: padLeft formatted correctly"
.
say "All text-cleanup tests passed."
# Demo for text-cleanup Blueprint
use "../../../../packs/otter-official/text-utils/src/main.ot"
say "=== Text Cleanup Blueprint Demo ==="
rawTitle is "Otter Language 2026 Release"
cleanSlug is slugify rawTitle
say "Slug:" cleanSlug
rawCode is "7"
paddedCode is padLeft rawCode 6 "0"
say "Zero-padded code:" paddedCode
Installation & Usage
otter blueprint explain otter-official/text-cleanup
otter blueprint apply otter-official/text-cleanup --project ./my-app
Converts titles into web-safe URL slugs (like 'my-first-post') and formats invoice numbers with zeros.