Skip to content

Your First Template

Leonard Ramminger edited this page Aug 22, 2026 · 1 revision

Your First Template

Tutorial: minimal template in ~10 minutes.

Goal

Template hello_app with a rendered README.md.

Step 1: Create folders

mkdir -p templates/hello_app/files

Step 2: template.lua

templates/hello_app/template.lua:

return {
  id = "hello_app",
  name = "Hello App",
  version = "0.1.0",
  description = "Minimal starter template",
  source_dir = "files",
  output = {
    path = "{{ project_slug }}",
    overwrite = false,
  },
}

Step 3: questions.lua

templates/hello_app/questions.lua:

return {
  order = { "Project" },
  groups = {
    Project = {
      {
        key = "project_name",
        type = "string",
        prompt = "Project name",
        default = "Hello App",
      },
      {
        key = "project_slug",
        type = "string",
        prompt = "Project slug",
        default = function(ctx)
          return slugify(ctx.values.project_name or "hello-app")
        end,
      },
    },
  },
}

Step 4: File

templates/hello_app/files/README.md.pbt:

# {{ project_name }}

Generated by Tempify.

Step 5: Validate & render

cd /path/to/workspace   # contains templates/
tempify validate hello_app
tempify hello_app /tmp/hello-out --set project_name="Demo"
cat /tmp/hello-out/README.md

Expected: # Demo

Step 6: Fixture test (optional)

mkdir -p templates/hello_app/tests/default/snapshot
# After first render, copy snapshot:
cp -r /tmp/hello-out/* templates/hello_app/tests/default/snapshot/
echo '{"project_name":"Demo","project_slug":"demo"}' > templates/hello_app/tests/default/answers.json
tempify test hello_app

Details: Template Tests

Next steps

Clone this wiki locally