Skip to content

Support Smarty (.tpl) templates as a recognized file type #1060

Open

Description

@HristovCodes

Summary

.tpl files (Smarty templates) are not in graphify's file-type map, so they're skipped entirely during graph builds.

In graphify/detect.py, classify_file() matches a file's extension against CODE_EXTENSIONS, DOC_EXTENSIONS, PAPER_EXTENSIONS, IMAGE_EXTENSIONS, etc. .tpl is in none of them, so classify_file() returns None and the file is never ingested — no AST pass, no semantic pass.

Why it matters

Smarty is a very common PHP templating engine (and .tpl is also used by other template systems). In template-heavy PHP codebases, .tpl files can be a large fraction of the project. For example, the repo I'm running graphify on has 261 .tpl files — roughly half the codebase — all silently omitted from the graph. The resulting graph misses the entire view layer: which controllers render which templates, {include file="..."} relationships, and the variables passed via $tpl->assign(...) / consumed as {$var}.

Suggested fix

Smarty has no tree-sitter grammar, so AST extraction isn't applicable. The natural fit is the document/semantic path. The minimal change is to add .tpl to DOC_EXTENSIONS so templates go through semantic LLM extraction:

DOC_EXTENSIONS = {'.tpl', '.md', '.mdx', '.qmd', '.txt', '.rst', '.html', '.yaml', '.yml'}

That alone makes templates first-class documents in the graph. As a follow-up, a lightweight regex extractor (similar to the existing Blade extractor in extract.py) could capture Smarty {include file=...} / {extends ...} edges and $smarty.* / assigned-variable usage for richer code↔view links.

Current workaround

I'm patching the installed package's DOC_EXTENSIONS from a wrapper script (idempotently, so it survives uv tool upgrade), but native support would be much better.

Environment

  • graphify CLI 0.8.22 (PyPI graphifyy), installed via uv tool install
  • Python 3.11, Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions