From 3551eb3b2c7f11c7abd0112831035c48831ed9d1 Mon Sep 17 00:00:00 2001 From: Spencer Brower <6729162+sbrow@users.noreply.github.com> Date: Mon, 10 Aug 2026 17:13:54 -0400 Subject: [PATCH] fix: Fixed diagnostic issue with first/last in partials. --- DIAGNOSTIC_TESTS.yaml | 18 ++++++++++-------- mustache/pipes.odin | 5 +++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/DIAGNOSTIC_TESTS.yaml b/DIAGNOSTIC_TESTS.yaml index 9458277..6a94fc0 100644 --- a/DIAGNOSTIC_TESTS.yaml +++ b/DIAGNOSTIC_TESTS.yaml @@ -343,19 +343,21 @@ should: ok expected: "foo" --- # TODO: called First/last, but only tests first +# TODO: Include | last 3 }} in the suggestion. name: "first/last in partial" enable: true input: "{{> footer }}" -should: error +should: warn expected: | first -3 is equivalent to last 3 - --> /home/spencer/github.com/sbrow.github.io/layouts/partials/footer.html:1:1 - | - 1 | + | --- name: "Pipes are ignored in comments" enable: true diff --git a/mustache/pipes.odin b/mustache/pipes.odin index 1e850bb..2aad0a8 100644 --- a/mustache/pipes.odin +++ b/mustache/pipes.odin @@ -460,14 +460,15 @@ take :: proc( any, Error, ) { - elem_info, count, data := list_info(value) + unwrapped, _ := base_value(value) + elem_info, count, data := list_info(unwrapped) is_list := elem_info != nil from_start := from_start warning: Error = nil str: string if !is_list { - s, is_str := reflect.as_string(value) + s, is_str := reflect.as_string(unwrapped) if !is_str { return nil, Error_Body { msg = "requires a list or string",