Update some files

This commit is contained in:
semihalev 2025-03-11 18:23:44 +03:00
commit 1e73b70e2f
3 changed files with 34 additions and 64 deletions

2
.gitignore vendored
View file

@ -1,4 +1,6 @@
test_temp/
twig.wiki/
.DS_Store
coverage.html
coverage.out

View file

@ -1,62 +1,30 @@
# Twig v1.0.1 Release Notes
# Twig v1.0.2 Release Notes
## Overview
## New Features
Twig v1.0.1 brings significant performance improvements, bug fixes, and new features to the Twig template engine for Go. This release focuses on memory efficiency, rendering speed, and overall stability with impressive benchmark results.
### Added New Tags
- **Apply Tag**: Implement `{% apply filter %}...{% endapply %}` tag that applies filters to blocks of content
- **Verbatim Tag**: Added `{% verbatim %}...{% endverbatim %}` tag to output Twig syntax without processing it
- **Do Tag**: Implement `{% do %}` tag for performing expressions without outputting results
## Performance Improvements
### Added New Filter
- **Spaceless Filter**: Added `spaceless` filter that removes whitespace between HTML tags
- **Object Pooling**: Implemented comprehensive object and token pooling for near-zero memory allocation during template rendering
- **Filter Chain Optimization**: Dramatically improved filter chain handling with optimized builder patterns and O(n) complexity
- **Attribute Caching**: Added efficient LRU eviction strategy for attribute cache to reduce reflection overhead
- **String Handling**: Optimized string to byte conversions during rendering for better performance
- **Template Serialization**: Optimized compiled template serialization for faster loading and smaller memory footprint
- **Concurrency**: Fixed lock contention in template loading for better multi-threaded performance
## Improvements
- **Path Resolution**: Fixed template path resolution for relative paths in templates
- Properly resolves paths starting with "./" or "../" relative to the current template's directory
- Enables templates in subdirectories to properly include/extend templates using relative paths
- **Code Organization**: Split parser functions into separate files for better maintainability
- **Documentation**: Updated README with new tags and filter documentation
- **Code Quality**: Cleaned up formatting and removed debug code
## Bug Fixes
## Comprehensive Testing
- Added tests for all new functionality:
- Verbatim tag tests
- Apply tag tests
- Spaceless filter tests
- From tag tests
- Relative path resolution tests
- Fixed goroutine leaks in render context error paths
- Fixed array filters and added support for GetItemNode and array access
- Fixed negative number handling in filter tests
- Improved regex handling for the `matches` operator
- Fixed short-circuit evaluation for logical operators
- Fixed range function inclusivity and map iteration tests
- Fixed advanced filters and error condition handling
- Fixed debug tests and improved debug functionality
- Fixed code style inconsistencies
## New Features and Improvements
- Added comprehensive macro benchmark tests and updated documentation
- Added serialization benchmarks and updated results
- Added HTML whitespace control and formatting enhancements
- Improved string rendering in scripts and JSON-style object handling
- Enhanced code style and documentation
- Improved README header presentation with new logo
- Added advanced macros examples
## Benchmark Results
Latest benchmark runs show dramatic performance improvements:
- Twig is now **57x faster** than Go's html/template for complex templates
- Memory usage reduced by **90%** compared to standard Go templates
- Performance on medium templates improved to 0.14 µs/op from 0.35 µs/op
- Simple template rendering improved to 0.28 µs/op from 0.47 µs/op
## Breaking Changes
None - This release maintains full compatibility with v1.0.0.
## Upgrading
This release is a drop-in replacement for Twig v1.0.0 with no changes required to your code or templates.
## Contributors
- @semihalev
- Claude (Co-Author)
## Full Changelog
For a full list of changes, see the [commit history](https://github.com/semihalev/twig/compare/v1.0.0...v1.0.1).
## Wiki Documentation
- Added comprehensive wiki pages for better documentation organization

View file

@ -229,7 +229,7 @@ widgets.twig - UI widgets</pre>
}
// Render each template
fmt.Println("===== ADVANCED MACRO EXAMPLES =====\n")
fmt.Println("===== ADVANCED MACRO EXAMPLES =====")
for _, name := range []string{"self_ref.twig", "scope.twig", "context.twig", "use_library.twig", "from_import.twig", "optimization.twig"} {
fmt.Printf("\n----- %s -----\n\n", name)
@ -240,6 +240,6 @@ widgets.twig - UI widgets</pre>
continue
}
fmt.Println("\n")
fmt.Println()
}
}