fix: Fixed diagnostic issue with first/last in partials.

This commit is contained in:
Spencer Brower
2026-08-10 17:15:38 -04:00
parent 3cb20b55e8
commit 3551eb3b2c
2 changed files with 13 additions and 10 deletions
+10 -8
View File
@@ -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 | <footer>
| ^ consider using the clearer form
2 | <menu>
3 | <a class="goto-top opacity-0" href="#">{{> icons/chevron_up}}</a>
|
--> /home/spencer/github.com/sbrow.github.io/thor/mustache/fixtures/layouts/partials/footer.html:11:78
|
9 | href="https://edwardtufte.github.io/tufte-css/">Tufte CSS</a>
10 | </p>
11 | <p><small>&copy;</small> {{! now | format "2006" }} {{params.author.name | first -3 }}</p>
| ^^^^^^^^ consider using the clearer form
12 | </footer>
|
---
name: "Pipes are ignored in comments"
enable: true
+3 -2
View File
@@ -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",