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

Layout and helpers? #76

Closed
holisticnetworking opened this issue Nov 18, 2016 · 8 comments
Closed

Layout and helpers? #76

holisticnetworking opened this issue Nov 18, 2016 · 8 comments

Comments

@holisticnetworking
Copy link

It would be especially nice to be able to use this plugin with some of my formatting helpers at my disposal.

@dereuromark
Copy link
Member

Isnt that possible using callables/closures?

@josegonzalez
Copy link
Member

@holisticnetworking how would you imagine that working?

@holisticnetworking
Copy link
Author

One way might be to specify a "formatter" callable for each field. Thus $_extract might look like such:

$_extract = [ ['price'] => 'NumberHelper::currency' [, 'col', 'col'] ]

@josegonzalez
Copy link
Member

Is this something you would be interested in building? I'm not sure how the user interface would be, and as the current formatting methods work fine for me, I'm not really inclined to write it.

We can help you with tests once the pr is up.

@holisticnetworking
Copy link
Author

holisticnetworking commented Nov 18, 2016

Let me look into the code a bit before I say something silly...

@holisticnetworking
Copy link
Author

I'm looking at the code, and while there is a variable created called "formatter," really, that's just an extraction function. It does not actually format anything in the sense of NumberHelper or similar functions. I'm going to play around with this some and see what I can do.

@dereuromark
Copy link
Member

dereuromark commented Nov 21, 2016

Something like this could indeed work:

$_formatters = [
    'price' => ['NumberHelper::currency' [, 'col', 'col']],
    'some_field' => function ($value) { //format }
    ....
]

And then apply those callable if available prior to finally formatting the output?

@ADmad
Copy link
Member

ADmad commented Feb 21, 2017

You are use callables in $_extract array to achieve whatever formatting you want for a field. The README has example for it.

@ADmad ADmad closed this as completed Feb 21, 2017
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

No branches or pull requests

4 participants