Render Liquid fields by default - #1584
Open
caitmich wants to merge 10 commits into
Open
Conversation
2 tasks
Introduce LiquidRenderContext, a thread-local context holder that controllers set before the view renders and clear afterwards. HasFields gains a raw_fields method (previous fields logic) and an updated fields method that renders Liquid values when context is present. set_field and delete_field now write raw_fields so rendered output is never persisted. LiquidEnabledResource registers an around_action to set the context for controllers that already include it (IssuesController, EvidenceController, etc.). This eliminates one-off Liquid rendering fixes per view. Any attribute read via fields or title in a request context is rendered automatically.
Tighten rescue to Liquid::Error (was StandardError), add filters: [] to match the existing liquid_filter.rb options, and update DiffedContent to call raw_fields throughout so rendered Liquid output is never written back to record.content or used as source for field sync operations.
caitmich
force-pushed
the
liquid/render-by-default
branch
from
May 1, 2026 15:24
d5a8235 to
1da08c5
Compare
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.
Problem
Liquid template tags in field values (e.g. `{{ project.name }}` in a Title or Description field) were not evaluated automatically. Each view that wanted rendered output had to opt in explicitly — calling a helper, passing assigns, or wiring up a filter. This led to inconsistent behaviour: the same field could appear raw in one place and rendered in another, and new views silently showed unrendered templates.
Solution
Render-by-default: `fields` and `title` on models always return Liquid-evaluated values in request contexts. `raw_fields` is the explicit escape hatch, used only when editing, diffing, or writing to the database.
Three moving parts:
1.
LiquidRenderContext(app/lib/liquid_render_context.rb, new)liquid_resource_assignshas been set).2. `HasFields#dradis_has_fields_for`
raw_fieldscontains the existing parser logic, unchanged.fieldsrenders viaLiquidRenderContext.renderwhen a context is present and memoizes the result on the instance.@_rendering_fields) prevents infinite loops when a field value references the same record's fields via a drop (e.g.{{ issue.fields['Impact'] }}inside another field).set_fieldanddelete_fieldwrite throughraw_fieldsso rendered output is never saved back to the database.titleinherits rendering automatically since it delegates tofields.fetch('Title', ...).3.
LiquidEnabledResource+ProjectScopedwith_liquid_render_contextlives inLiquidEnabledResource, which is now included byProjectScoped. All project-scoped controllers get Liquid rendering automatically. Non-project controllers that need it (e.g.MarkupController) includeLiquidEnabledResourcedirectly.DiffedContentis updated to useraw_fieldsso sync and diff operations always work on raw Liquid templates.Testing Steps
Check List