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

[5.x] Allow setting tag pair content from fluent tags #11018

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

daun
Copy link
Contributor

@daun daun commented Oct 27, 2024

Some of our recent projects use third-party templating languages and would benefit from being able to set the content of tag pairs when emulating Antlers tags. That's what this PR would allow.

So to emulate...

{{ dictionary handle="countries" }}
    {{ label }}
{{ /dictionary }}

One could do the following...

Statamic::tag('dictionary')
  ->params(['handle' => 'countries'])
  ->withContent('{{ label }}')
  ->fetch();

@JohnathonKoster
Copy link
Contributor

Neat!

There is possibly a breaking change if someone is calling a tag that has a content param using the method-style (vs. calling params) 🤔

@daun
Copy link
Contributor Author

daun commented Oct 27, 2024

@JohnathonKoster Good point. To err on the safe side, the new content method could just set a content param as well. Probably still breaking if it expects empty inner content between tags. Or rename the method to withContent or setContent...

@jasonvarga
Copy link
Member

Or rename the method to withContent

That'll do. 👍

@daun
Copy link
Contributor Author

daun commented Oct 28, 2024

@jasonvarga Updated to use withContent() instead.

@jasonvarga jasonvarga merged commit b75055b into statamic:5.x Oct 28, 2024
18 checks passed
@daun daun deleted the feature/fluent-tag-content branch October 28, 2024 19:33
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 this pull request may close these issues.

3 participants