statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Where modifier not working in partial with dynamic key #2538

Open hmalaud opened 3 years ago

hmalaud commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Create globals set with array of objects:

dev.yaml -->
data:
  full_images:
    - image_width: 1920
      media_query: "(orientation: landscape) and (min-width: 1920px)"
      default_size: false
      type: size
      is_portrait: false
      enabled: true
    - image_width: 1920
      media_query: "(orientation: landscape) and (min-width: 1600px)"
      default_size: false
      type: size
      is_portrait: false
      enabled: true
    - image_width: 1440
      media_query: "(orientation: landscape) and (min-width: 1440px)"
      default_size: false
      type: size
      is_portrait: false
      enabled: true
    - image_width: 1280
      media_query: "(orientation: landscape) and (min-width: 1280px)"
      default_size: true
      type: size
      is_portrait: false
      enabled: true
    - image_width: 1152
      image_height: 2050
      media_query: "(orientation: portrait) and (min-width: 1152px)"
      default_size: false
      type: size
      is_portrait: false
      enabled: true
    - image_width: 580
      image_height: 1000
      media_query: "(orientation: portrait)"
      default_size: false
      type: size
      is_portrait: false
      enabled: true

Loop in partial

my_partial.antlers.html -->
   {{ dev:full_images }}
      Working fine!
   {{ /dev:full_images }}

Add modifier:

   {{ dev:full_images where="default_size:1" }}
      Only one output: still working fine!
   {{ /dev:full_images }}

(Don't know if that's another bug but using with group_by throws an error array_key_exists(): Argument #1 ($key) must be a valid array offset type, but that's not why I'm here for)

Use dynamic key as a parameter on the partial call

      {{ partial:partials/picture gset="full_images" }}

Loop in partial

   {{ dev[gset] }}
      Still working fine!
   {{ /dev[gset] }}

Add modifier:

   {{ dev[gset] where="default_size:1" }}
      No output, not working anymore
   {{ /dev[gset] }}

Expected behavior Expects behavior to be the same with dynamic key value or static variable name.

Environment details (please complete the following information):