PHPackages                             wuhhh/template-genie - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. wuhhh/template-genie

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

wuhhh/template-genie
====================

A Craft CMS plugin for scaffolding Twig templates based on CMS setup with field-aware variable definitions

v1.0.0-alpha(4mo ago)016[2 issues](https://github.com/wuhhh/template-genie/issues)proprietaryPHPPHP ^8.2

Since Aug 13Pushed 4mo agoCompare

[ Source](https://github.com/wuhhh/template-genie)[ Packagist](https://packagist.org/packages/wuhhh/template-genie)[ RSS](/packages/wuhhh-template-genie/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Template Genie Plugin for Craft CMS
===================================

[](#template-genie-plugin-for-craft-cms)

A Craft CMS plugin that scaffolds Twig templates and partials based on your CMS structure, with intelligent field-aware variable definitions and sensible defaults.

What It Does
------------

[](#what-it-does)

Template Genie analyzes your Craft CMS setup and generates:

- **Section templates** - Entry point templates that delegate rendering to partials
- **Entry type partials** - Field-aware templates with proper variable assignments
- **Matrix/Content Block partials** - Nested element templates for complex fields
- **Smart HTML output** - Optional semantic HTML rendering for rapid prototyping

The plugin understands all 29 native Craft CMS field types (100% coverage) and generates appropriate variable assignments, null coalescing patterns, and helpful context comments.

Key Features
------------

[](#key-features)

- **Complete field support** - All native Craft 5 fields including Content Block
- **Smart variable assignment** - Automatically handles `.one()` vs `.all()` based on relation limits
- **Context-aware comments** - Field constraints, options, and limits included inline
- **Layout integration** - Apply Twig layouts during generation
- **Interactive mode** - User-friendly prompts for configuration
- **Selective generation** - Generate templates only, partials only, or specific sections
- **Safe overwrite handling** - Prompts before overwriting existing files

Installation
------------

[](#installation)

This plugin is available via Packagist:

```
composer require wuhhh/template-genie
./craft plugin/install template-genie && ./craft plugin/enable template-genie
```

Basic Usage
-----------

[](#basic-usage)

### Interactive Mode (Recommended)

[](#interactive-mode-recommended)

Simply run the command with no options for an interactive setup wizard:

```
./craft template-genie/generate
```

The interactive mode will guide you through:

- Section selection
- Template vs partial generation
- Layout file selection
- Output style preferences
- Overwrite behavior

### Command Line Options

[](#command-line-options)

Generate templates and partials for specific sections:

```
# Generate everything for specific sections
./craft template-genie/generate --sections=blog,news

# Generate only section templates
./craft template-genie/generate --sections=blog --templates-only

# Generate only partials
./craft template-genie/generate --sections=blog --partials-only

# Force overwrite without prompts
./craft template-genie/generate --sections=blog -f

# Generate all sections
./craft template-genie/generate --all
```

### Advanced Options

[](#advanced-options)

```
# Apply a layout file during generation
./craft template-genie/generate --sections=blog --layout-file=_layouts/base.twig

# Specify custom block name (default: 'content')
./craft template-genie/generate --sections=blog --layout-file=_layouts/base.twig --block-name=main

# Generate with HTML output for rapid prototyping
./craft template-genie/generate --sections=blog --output-style=full --with-output

# Wrap entry type partials in semantic elements
./craft template-genie/generate --sections=blog --wrap-entry-type
```

Output Styles
-------------

[](#output-styles)

Template Genie supports different output styles:

### Minimal (Default)

[](#minimal-default)

Generates only variable assignments with context comments:

```
{# Blog Post #}
{% set title = entry.title ?? null %}
{% set featuredImage = entry.featuredImage.one() ?? null %}
{% set body = entry.body ?? null %}
```

### Full

[](#full)

Includes semantic HTML rendering for rapid prototyping:

```
{# Blog Post #}
{% set title = entry.title ?? null %}
{% set featuredImage = entry.featuredImage.one() ?? null %}
{% set body = entry.body ?? null %}

  {{ title }}
  {% if featuredImage %}

  {% endif %}
  {{ body }}

```

How It Works
------------

[](#how-it-works)

### Section Templates

[](#section-templates)

For sections with defined template paths, Template Genie generates entry point templates that delegate to partials:

```
{# templates/blog/_entry.twig #}
{{ entry.render() }}
```

### Entry Type Partials

[](#entry-type-partials)

Partials are generated at `_partials/entry/{entryTypeHandle}.twig` with field-aware variables:

```
{# _partials/entry/blogPost.twig #}
{# Blog Post #}
{% set title = entry.title ?? null %}
{% set author = entry.author.one() ?? null %}
{% set categories = entry.categories.all() ?? [] %}
{% set featuredImage = entry.featuredImage.one() ?? null %}
{% set body = entry.body ?? null %}
{% set publishDate = entry.publishDate ?? null %}
```

### Smart Field Handling

[](#smart-field-handling)

The plugin detects field configuration and generates appropriate patterns:

**Single vs Multi Relations:**

```
{# Single relation (maxRelations = 1) #}
{% set featuredImage = entry.featuredImage.one() ?? null %}

{# Multi relation (maxRelations > 1 or null) #}
{% set gallery = entry.gallery.all() ?? [] %}
```

**Field Constraints:**

```
{# Product description (160 char limit, no line breaks) #}
{% set description = entry.description ?? null %}

{# Gallery images (min 2, max 8 selections) #}
{% set galleryImages = entry.galleryImages.all() ?? [] %}
```

**Field Options:**

```
{# Background color (options: aquamarine|turquoise|teal|whitesmoke) #}
{% set backgroundColor = entry.backgroundColor.value ?? null %}
```

Field Support
-------------

[](#field-support)

Template Genie supports all 29 native Craft CMS field types with intelligent handling:

- Addresses, Assets, Button Group, Categories, Checkboxes
- Color, Content Block, Country, Date, Dropdown
- Email, Entries, Icon, JSON, Lightswitch
- Link, Matrix, Money, Multi-select, Number
- Plain Text, Radio Buttons, Range, Table, Tags
- Time, Users

Each field type receives appropriate:

- Variable assignment pattern
- Null coalescing behavior
- Context comments with constraints
- Optional HTML rendering

Tips
----

[](#tips)

- **Use `.render()`** - Generated partials work automatically with Craft's render delegation
- **Matrix fields** - Matrix block partials are auto-generated, use `{{ block.render() }}`
- **Layouts** - Apply layouts during generation to wrap templates in your site structure
- **Force mode** - Use `-f` flag in CI/CD pipelines to skip prompts
- **Sections only** - Skip sections without template paths (valid for Channel sections)

Requirements
------------

[](#requirements)

- Craft CMS ^5.0.0
- PHP ^8.2

License
-------

[](#license)

Proprietary - Commercial plugin for Craft CMS

Support
-------

[](#support)

- **Documentation:**
- **Issues:**

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance74

Regular maintenance activity

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

146d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19ce4ad4e1209ff16384235e4f79ef5883ed783d2b355ee7d37e10816d79eb42?d=identicon)[wuhhh](/maintainers/wuhhh)

---

Tags

twigscaffoldingcmstemplatesCraftcraftcmscraft-plugintemplate-genie

### Embed Badge

![Health badge](/badges/wuhhh-template-genie/health.svg)

```
[![Health](https://phpackages.com/badges/wuhhh-template-genie/health.svg)](https://phpackages.com/packages/wuhhh-template-genie)
```

###  Alternatives

[wbrowar/guide

A CMS Guide for Craft CMS.

6154.5k1](/packages/wbrowar-guide)[jalendport/craft-preparse

A fieldtype that parses Twig when an element is saved and saves the result as plain text.

1086.4k](/packages/jalendport-craft-preparse)[nystudio107/craft-autocomplete

Provides Twig template IDE autocomplete of Craft CMS &amp; plugin variables

44204.4k13](/packages/nystudio107-craft-autocomplete)[viget/craft-classnames

Classnames plugin for Craft CMS

1115.5k1](/packages/viget-craft-classnames)[verbb/footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

213.3k](/packages/verbb-footnotes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
