Fixed the issue with relative path resolution by:
1. Adding a directory field to Template struct to store template's path
2. Adding lastLoadedTemplate field to RenderContext to track template context
3. Updating Clone method to preserve lastLoadedTemplate reference
4. Setting lastLoadedTemplate in all render contexts to maintain path context
This ensures that when templates include/extend/import other templates
using relative paths (starting with ./ or ../), the paths are properly
resolved relative to the original template's location.
- Implemented pooled slices for function arguments
- Added specialized pooling for variable node and literal node objects
- Modified array and hash node evaluation to reduce allocations
- Optimized test and filter evaluation with pooled resources
- Added comprehensive benchmarks to validate improvements
- Updated node pool implementation to remove duplicate declarations
- Fixed memory allocations in merge filter to correctly handle array manipulations
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implement SecurityPolicy interface with function/filter/tag restrictions
- Add DefaultSecurityPolicy with sensible defaults for common operations
- Add sandboxed option to include tag for secure template inclusion
- Implement context-level sandbox flag and methods
- Add engine-level sandbox control methods
- Create comprehensive tests for sandbox functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add sandboxed option to include tag
- Implement SecurityPolicy interface and DefaultSecurityPolicy
- Support restricting function calls, filters, and more in sandbox mode
- Add tests for sandbox functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit implements the parent() function in the Twig template engine,
which allows child templates to access parent template block content when
overriding blocks. The implementation supports:
- Basic single-level parent() calls (child accessing parent content)
- Tracking of original block content through template inheritance chain
- Prevention of infinite recursion in parent() function calls
- Comprehensive test suite for parent() functionality
Future work may include full multi-level inheritance support for nested
parent() calls (child -> parent -> grandparent).
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added tracking of last access time and access count to cache entries
- Implemented eviction policy to remove least recently/frequently used entries
- Cache now removes 10% of entries when the cache is full, prioritizing by usage
- Added benchmarks and tests to verify eviction strategy
- Fixed the previously ineffective eviction strategy
- Improved cache efficiency for applications with many diverse object types
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit introduces two major performance improvements:
1. Memory optimization in string handling
- Pre-allocates slice capacities to reduce reallocations
- Uses string builders with pre-allocated capacity
- Avoids unnecessary string concatenations and conversions
- Optimizes pattern matching code to reduce allocations
- Reuses memory for string slices where possible
2. Fixed unbounded attribute cache growth
- Added maximum cache size limit (1000 entries)
- Implemented simple cache eviction strategy
- Tracks current cache size with counter
- Prevents potential memory leaks in long-running applications
These changes significantly reduce memory allocations and improve
performance, especially for large templates.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed macro parameter parsing with improved tokenization handling
- Added support for proper module.function() syntax in templates
- Enhanced filter handling within macro variables
- Added support for variable interpolation in macro body
- Added comprehensive test suite for macros with various scenarios
- Improved overall coverage from 43.8% to 45.7%
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit fixes the TestArrayFilters tests by implementing proper support for array access and map literals in the template engine. Key improvements include:
1. Added support for GetItemNode to handle array access with square brackets
2. Implemented parseMapExpression to handle map/object literals with curly braces
3. Fixed string ordering in the Keys filter by adding proper sorting
4. Added support for array access in variable attributes
5. Improved the expression parsing to handle chained operators properly
These changes allow complex expressions like {{ people[0].name }} to work correctly
and ensure that array filters like sort, keys, and merge function properly.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This fixes expressions like {% if foo is defined and foo > 5 %} when foo is undefined.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implement proper short-circuit evaluation for 'and' and 'or' operators
- Fix issue with expressions like 'foo is defined and foo > 5' when foo is undefined
- Modify EvaluateExpression to skip evaluating right side of logical expressions when not needed
- Update documentation with findings and solutions
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Update documentation with negative step range workaround
- Document limitations and solutions in FINDINGS.md and SOLUTION.md
- Clean up code style and remove experimental files
- Optimize performance in core functions
- Fix whitespace and end-of-file newlines
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added configuration options for whitespace preservation in HTML
- Implemented proper spacing around HTML tags for readability
- Added special handling for script and style tags to preserve their content
- Improved detection of HTML content vs. plain text
- Added options to control HTML attribute formatting
- Fixed handling of quote marks in various contexts
- Added comprehensive tests for whitespace preservation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Enhance parseInclude to support JSON-style object literals with braces
- Add special handling for JavaScript values to ensure proper quoting
- Preserve CSS formatting for units, colors, and font-family values
- Fix type detection to avoid quoting numbers and booleans in scripts
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added enhanced error reporting with source context
- Implemented debug logging system with multiple verbosity levels
- Added memory pooling for render contexts and string buffers
- Implemented better error messages with template name and line information
- Fixed concurrency issues in template loading
- Added improved attribute reflection caching
- Created comprehensive tests for all new features
- Updated documentation with debugging examples
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implement a compiled template format using gob encoding
- Add methods to compile templates and load from compiled templates
- Create dedicated CompiledLoader for managing compiled templates
- Enable auto-reload support for compiled templates
- Add comprehensive tests including benchmarks
- Create example application for template compilation workflow
- Update documentation with compilation features and examples
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Implement template modification time tracking for auto-reload
- Add TimestampAwareLoader interface and implementation
- Improve caching with proper reload when files change
- Optimize filter chain processing for better performance
- Add benchmarks for filter chain optimization
- Update documentation with new features
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added methods to execute macros and handle imported macros
- Implemented ImportNode and FromImportNode for template imports
- Added CallFunction method to support function and macro calls
- Enhanced PrintNode to handle callable macro results
- Updated parseMacro, parseImport, and parseFrom methods
- Added NullWriter for importing macros without output
- Fixed parser handling of endmacro tags
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>