Commit graph

4 commits

Author SHA1 Message Date
semihalev
529420e7f2 Fix template fallback mechanism to only execute for not found errors
- Modified ExtendsNode, IncludeNode, ImportNode, and FromImportNode to only fallback when specifically dealing with ErrTemplateNotFound
- When a syntax error or other functional error occurs in templates, the real error is now displayed instead of silently falling back to other templates
- Added proper error type checking with errors.Is() to ensure correct fallback behavior
- Improved ignoreMissing behavior in IncludeNode to only apply to not found errors

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-12 20:47:20 +03:00
semihalev
435bb12ac3 Optimize expression evaluation to reduce allocations
- 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>
2025-03-12 03:04:36 +03:00
semihalev
b44bad903b Implement spaceless filter and apply tag
1. Added spaceless filter that removes whitespace between HTML tags
2. Implemented {% apply filter %} ... {% endapply %} tag
3. Updated spaceless tag to use the spaceless filter internally
4. Fixed endverbatim tag handling
5. Added tests for all new functionality

The apply tag allows applying filters to blocks of content, which is the
modern recommended approach in Twig, replacing the deprecated spaceless tag.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-11 17:28:57 +03:00
semihalev
8809c704bb Fix template path resolution for relative paths
Implements proper resolution of relative paths in templates.
When a template in a subdirectory uses a relative path (starting with "./" or "../")
in an include, extend, import, or from-import directive, the engine now correctly
resolves the path relative to the current template's directory first.

This fixes issues where templates in subdirectories couldn't properly
include/extend templates using relative paths.

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-11 17:07:05 +03:00