How sayi/poi-tl works
Main Components
• Core Template Engine (poi-tl): This module (under the “poi-tl” directory) orchestrates the template parsing, tag evaluation, and document generation. It contains packages for configuration, expressions, template parsing/resolving, rendering policies, and utilities.
• Plugin Modules: There are separate modules such as:
– poi-tl-plugin-highlight for code highlighting.
– poi-tl-plugin-markdown for transforming Markdown content into Word.
These plugins extend the base functionality through custom render policies and converters.
• CLI Module (poi-tl-cli): Provides a command‐line interface to drive the template engine.
• JSON Model Support (poi-tl-jsonmodel-support): Supplies additional support for mapping JSON data to rendering models.
• Schema Extension (poi-ooxml-schemas-extra): Contains additional or modified Apache POI XML schemas to support more features or custom elements in Word processing.
Layered and Modular Architecture
• At the lowest layer, include third-party libraries and dependencies:
– Apache POI (versions 3.16+ up to 5.1.0 and later) for low-level Word document operations.
– Other build and configuration files (pom.xml, .travis.yml, etc.) that facilitate integration and deployment.
• The Core Engine layer uses these libraries and handles parsing, template merging, tag replacement, and style management.
• The Plugin layer sits on top of the core engine and provides additional functionality. This layer should detail how the core engine “plugs in” custom functions (like those managing Markdown or syntax highlighting).
• The Utility layer comprises supporting packages (e.g., converters, resolvers, renderers, and common utilities) that enrich the processing workflow.
• The Client Access layer includes the CLI and any external APIs or integration points (like JSON input handling) that allow users or downstream systems to interact with the engine.
• That the Core Engine makes calls to Apache POI and the extended schema module (poi-ooxml-schemas-extra) to manipulate and generate Word documents.
• Dependency flows: for example, the JSON Model Support module feeds data models into the template resolution process.
Architectural Patterns and Design Principles
• Use a layered architecture (presentation/command layer; core business/template engine; plugin/extension modules; and integration with external libraries).
• Modularity and extensibility: the plugins and custom functions illustrate the pluggable architecture.
• “logic-less” design pattern, where only tag placeholders are used in templates, keeping business logic separated from the presentation.
• Use of builder patterns in configuration (e.g., ConfigureBuilder in the core module) and abstract render policies that allow for different rendering behaviors.
Instructing the Principal Software Engineer
– “XWPFTemplate (Core Engine): Handles template compilation, rendering and document generation.”
– “Highlight Plugin: Converts code blocks via custom render policies.”