Skip to content

v1.0.3

Latest
Compare
Choose a tag to compare
@semihalev semihalev released this 11 Mar 20:19
· 18 commits to main since this release

Twig v1.0.3

New Features

Security Enhancement

  • Sandbox Mode: Added comprehensive sandbox security system for templates
    • Implemented a SecurityPolicy interface to restrict allowed functions, filters, and tags
    • Added DefaultSecurityPolicy with safe defaults for common operations
    • Added sandboxed option to include tag for secure template inclusion
    • Added engine-level sandbox control methods: EnableSandbox() and DisableSandbox()

Template Inheritance Enhancement

  • Parent Function: Implemented parent() function for accessing parent block content
    • Allows child templates to extend rather than completely replace block content
    • Preserves proper inheritance chain for multi-level inheritance
    • Enhanced block context tracking for proper parent reference resolution

Whitespace Control

  • Dash Modifiers: Added support for whitespace control with dash modifiers (-)
    • Added support for {{- ... }} and {{ ... -}} to trim whitespace before/after output
    • Added support for {%- ... %} and {% ... -%} to trim whitespace before/after block tags
    • Preserves template readability while controlling output formatting

Improvements

  • Code Organization: Enhanced internal APIs for better maintainability
  • Documentation: Updated README and wiki with new features
  • Code Quality: Improved error handling and memory management
  • Performance: Optimized context handling for sandboxed includes

Documentation

  • Updated README with detailed information about new features
  • Added comprehensive wiki pages for Sandbox Mode, Parent Function, and Whitespace Control
  • Updated release notes with detailed information about changes