Skip to content

theme() helper dot notation removes arrays #497

@manda-ikaink

Description

@manda-ikaink

Describe the issue

When using theme() helper to access values from the theme.json file, it will return a string value as expected. But if something is formatted as an array, the dot notation built into the helper flattens and formats the array.

To reproduce

This specific issue came up when wanting to define a list of supported languages for a theme. JSON looks like this:

"languages": [
    {
        "name": "English",
        "value": "en"
    }
]

And I'm trying to access and loop through the values like so in my view file:

@foreach (theme('languages') as $lang)
    <a href="{{ url('locale/' . $lang->value) }}">{{ $lang->name }}</a>
@endforeach

But the array is being flattened into the following way, making the data inaccessible:

Screen Shot 2020-05-06 at 3 52 59 PM

Version and browser

Version: Master

Bug report checklist

  • I have filled out as much information as I can
  • I have detailed how the issue can be reproduced
  • I have searched for existing issues and to the best of my knowledge this is not a duplicate

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions