Class FragmentTraceHandler

java.lang.Object
org.thymeleaf.engine.AbstractTemplateHandler
io.karatelabs.markup.FragmentTraceHandler
All Implemented Interfaces:
org.thymeleaf.engine.ITemplateHandler

public class FragmentTraceHandler extends org.thymeleaf.engine.AbstractTemplateHandler
Devmode post-processor that emits paired <!-- ka:fragment-begin --> / <!-- ka:fragment-end --> comments around every fragment resolution and suppresses the synthetic <ka-trace> wrapper element that TraceWrappingHandler injected at processor time.

For each open <ka-trace> tag:

  1. Emit a begin comment with kind, fragment expression, depth, and the raw th:with payload from the call site.
  2. SUPPRESS the open tag (don't forward it).
  3. Push a frame onto a depth stack.
For each close <ka-trace> tag: pop the frame, suppress the close tag, emit the end comment.

All other tags (host elements, fragment content) pass through unchanged. Untraced templates pay only an O(1) tag-name comparison per element.

The handler is registered ONLY when devTrace + devMode is enabled (see IPostProcessorDialect.getPostProcessors()); zero production overhead.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handleCloseElement(org.thymeleaf.model.ICloseElementTag tag)
     
    void
    handleOpenElement(org.thymeleaf.model.IOpenElementTag tag)
     
    void
    handleStandaloneElement(org.thymeleaf.model.IStandaloneElementTag tag)
     

    Methods inherited from class org.thymeleaf.engine.AbstractTemplateHandler

    getContext, getNext, handleCDATASection, handleComment, handleDocType, handleProcessingInstruction, handleTemplateEnd, handleTemplateStart, handleText, handleXMLDeclaration, setContext, setNext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FragmentTraceHandler

      public FragmentTraceHandler()
  • Method Details

    • handleOpenElement

      public void handleOpenElement(org.thymeleaf.model.IOpenElementTag tag)
      Specified by:
      handleOpenElement in interface org.thymeleaf.engine.ITemplateHandler
      Overrides:
      handleOpenElement in class org.thymeleaf.engine.AbstractTemplateHandler
    • handleCloseElement

      public void handleCloseElement(org.thymeleaf.model.ICloseElementTag tag)
      Specified by:
      handleCloseElement in interface org.thymeleaf.engine.ITemplateHandler
      Overrides:
      handleCloseElement in class org.thymeleaf.engine.AbstractTemplateHandler
    • handleStandaloneElement

      public void handleStandaloneElement(org.thymeleaf.model.IStandaloneElementTag tag)
      Specified by:
      handleStandaloneElement in interface org.thymeleaf.engine.ITemplateHandler
      Overrides:
      handleStandaloneElement in class org.thymeleaf.engine.AbstractTemplateHandler