Skip to content

Conversation

@riasvdv
Copy link
Contributor

@riasvdv riasvdv commented Oct 22, 2020

This adds a nice helper function for people using Blade, which allows for {{ modify($value)->nl2br() }} for example

This adds a nice helper function for people using Blade, which allows for `{{ modify($value)->nl2br() }}` for example
@jasonvarga
Copy link
Member

With the trend being against global functions, I'm hesitant to add this. Especially with such a generic name. 🤔 It's a good idea though. I wonder if there's a better solution?

@riasvdv
Copy link
Contributor Author

riasvdv commented Oct 22, 2020

This feels to me like the collect() helper, which is used a lot and generally people have no issue with, a directive was my first idea, but you wouldn't be able to have chaining

@riasvdv
Copy link
Contributor Author

riasvdv commented Oct 22, 2020

It is only a one-liner though, so maybe it would be enough to just add it to the docs and people can add it to their projects if they need it

@riasvdv riasvdv closed this Oct 23, 2020
@jonassiewertsen
Copy link
Contributor

I would like this helper a lot, but do see Jasons point.

It may be possible or nice having more helper functions. So what about a statamic_FUNCTION naming.

In this case:

statamic_modify()

Still global, but less generic.

@riasvdv
Copy link
Contributor Author

riasvdv commented Oct 23, 2020

I've added a PR to the docs: statamic/docs#290

@jackmcdade
Copy link
Member

I think this would be a nice add. Especially since it’s SO generic outside of the “modifier” namespace that any other global function would probably a noun attached. Eg “modifySomething”.

@jasonvarga
Copy link
Member

@jackmcdade I agree with your reasoning here. But do you feel the same way about tag() in #2724? I could definitely see people using their own tag() for other things. If we have to come up with another convention for that one, we might want to apply it to this one.

@jasonvarga
Copy link
Member

Gonna hold off on this for now and suggest devs plop it in their own helpers file. Thanks!

@jasonvarga jasonvarga closed this Nov 23, 2020
@jesseleite jesseleite mentioned this pull request Jan 12, 2022
4 tasks
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.

4 participants