Skip to content

Add template render type with per-section model resolution#14

Merged
nicpottier merged 4 commits intomainfrom
nicpottier/render-strategies
Feb 11, 2026
Merged

Add template render type with per-section model resolution#14
nicpottier merged 4 commits intomainfrom
nicpottier/render-strategies

Conversation

@nicpottier
Copy link
Contributor

@nicpottier nicpottier commented Feb 11, 2026

Summary

Implement a config-driven render strategy system with support for both LLM-based and deterministic Liquid template rendering. Each section type can be mapped to a named strategy with its own render type and configuration.

Key Changes

  • Render Strategy System: Named strategies (render_strategies) with render_type ("llm" or "template") and type-specific config. Section types map to strategies via section_render_strategies, with default_render_strategy as fallback.
  • Template Render Type: New template render type using Liquid templates from /templates/ for fast, deterministic rendering without LLM calls.
  • Per-Section Model Resolution: Different LLM models can be used for different section types via strategy configuration, with lazy model instantiation and caching.
  • Code Split: Rendering logic split into render-llm.ts (LLM-based) and render-template.ts (Liquid templates), orchestrated by web-rendering.ts.
  • XSS Prevention: All template outputs use Liquid | escape filters to prevent HTML injection.

Test Plan

  • Strategy resolver tests: default, section-specific, fallback, missing strategy, template type
  • Template rendering tests: basic rendering, image URL rewriting, metadata, validation, mixed content
  • Real template tests against two_column_render.liquid (single text, two columns, two images, XSS)
  • Per-section model resolution test
  • All 271 tests pass, typecheck clean

Introduce a render strategy system that maps section types to named
strategies, each combining a render type with its configuration.
Two render types are supported: "html" (LLM-based, existing behavior)
and "template" (deterministic Liquid templates, no LLM call).

- Add RenderType, RenderStrategyConfig to AppConfig schema
- Split rendering into render-html.ts and render-template.ts
- Refactor web-rendering.ts with SectionPart union type, resolveParts,
  and dispatcher that routes to html or template renderer
- Add createTemplateEngine (plain Liquid, no custom tags)
- Template output validated with same validateSectionHtml as LLM output
- Update config.yaml with render_strategies and two_column template
- Add two_column_render.liquid template
- 266 tests passing
…mprovements

- Support per-section LLM model resolution with cached model instances
- Add XSS escaping (| escape filters) to all template outputs
- Improve HTML validation with stricter section tag checks
- Update callers (cli, pipeline-runner, page-edit-service) for model resolver pattern
- Add tests for strategy fallback, per-section models, XSS escaping, and validation
All render types produce HTML, so "html" was misleading. Renamed to "llm"
to clearly distinguish LLM-based rendering from template-based rendering.
@nicpottier nicpottier merged commit af92548 into main Feb 11, 2026
1 check passed
@nicpottier nicpottier deleted the nicpottier/render-strategies branch February 11, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant