feat: Features - filesystem, hash functions - #9
Merged
Conversation
…ttern
- Add new filter_env() custom function for glob-pattern matching of environment variables
- Supports wildcards: * (any characters) and ? (single character)
- Returns sorted array of {key, value} objects
- Add regex dependency for pattern matching
- Add comprehensive unit tests for filter_env function
- Add integration test with fixtures
- Add example template (examples/server-config.tmpl)
- Update README with filter_env documentation and examples
- Update features list to mention filter_env
The filter_env() function allows users to filter environment variables by pattern
(e.g., filter_env(pattern="SERVER_*")) and iterate over matching variables in templates.
This is useful for generating configuration files, export scripts, and environment-specific
settings without hardcoding variable names.
Example usage:
{% for var in filter_env(pattern="SERVER_*") %}
{{ var.key }}={{ var.value }}
{% endfor %}
- Add format_tera_error() function to format errors with detailed context
- Show line numbers, column positions, and expected tokens for parse errors
- Display variable names and context for runtime errors
- Show function call failures with argument details
- Include full error chain (error causes) in output
Before:
Error: Failed to parse template: Failed to parse 'template'
After:
Failed to parse template
Error: Failed to parse 'template'
Caused by:
--> 4:1
|
4 |
| ^---
|
= expected `%}` or `-%}`
This makes debugging templates much easier by providing actionable error messages
with precise locations and clear explanations of what went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.