Skip to content

Add strict validation for TemplateLogic subclass in TemplateArchiveProcessor compilation #163

Description

@23harshitkumar

Description

Currently, when compiling logic via TemplateArchiveProcessor, the template-engine evaluator supports two flavors of logic: one with a TemplateLogic instance and another with a plain JS function.

However, external execution environments (like the Web Worker Sandbox in template-playground) strictly require the compiled output to contain a class extending TemplateLogic so it can be instantiated dynamically.

Proposal

Instead of consumer applications having to manually regex-parse the compiled string (e.g. code.match(/class\s+(\w+)\s+extends\s+TemplateLogic/)) to validate the output, it would be much more robust to handle this validation directly within TemplateArchiveProcessor.

The compile method could either:

  1. Automatically throw a compilation error if a valid TemplateLogic class definition isn't found.
  2. Accept a strict flag (e.g., requireTemplateLogic: true) that enforces this validation during the compilation step.

Context

This was brought up during the review of the Sandboxed Logic Execution pipeline for the Template Playground: accordproject/template-playground#932 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions