mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 20:00:29 +01:00
[PR #108] [MERGED] Lazily render variables #44
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mountain-loop/yaak/pull/108
Author: @gschier
Created: 9/24/2024
Status: ✅ Merged
Merged: 9/24/2024
Merged by: @gschier
Base:
master← Head:lazy-variable-rendering📝 Commits (1)
4ccd4d8Lazily render variables (Fixes #107)📊 Changes
2 files changed (+25 additions, -29 deletions)
View changed files
📝
src-tauri/src/render.rs(+5 -28)📝
src-tauri/yaak_templates/src/renderer.rs(+20 -1)📄 Description
This PR restructures how environment variable values are rendered during the render pipeline, to eliminate the chances of accidental infinite recursion.
Before: The environment was recursively rendered and passed into another render call to render this actual thing (eg. request). This meant that ALL variables were rendered, even when not used. This also meant that template functions (eg.
response()) that called render again could potentially enter an infinite render loop.After:: Now, an environment variable is only rendered if it was referenced in the thing (eg. request). If a variable was referenced, its value is looked up and rendered again. This means the only way to enter infinite recursion is if a variable tries to render itself. This would be user error, however (we should also add detection for this case to warn the user).
Fixes #107
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.