Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output array from custom tag as var rather than iterable tag pair #364

Closed
jesseleite opened this issue Oct 8, 2020 · 1 comment · Fixed by statamic/cms#4257
Closed

Comments

@jesseleite
Copy link
Member

If I make a custom antlers tag and return an array of data, I know we can iterate over using a tag pair:

{{ my_tag_array_data }}
    {{ title }}
    {{ author }}
{{ /my_tag_array_data }}

But what if I want to pass that data into a vue component:

<my-component :some-prop='{{ my_tag_array_data | to_json }}'>

Maybe the user could explicitly set $isPair = false in the custom tag, or maybe antlers could detect if modifiers are used?We

@jasonvarga
Copy link
Member

Another idea I had could be a Variable class that works similar to a Tags class, but doesn't have parameters.

Any parameters on it would actually be treated like modifiers.

class MyVariable
{
  public function value()
  {
    return 'something';
  }
}
{{ my_variable | upper }} // SOMETHING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants