Open gabiudrescu opened 4 years ago
The twig context is a map of variable names to variable values. I don't see how you would define that in a CSV format.
well, I had this JSON exported from PHPStorm (DataGrip) and couldn't use it with twigfiddle as I didn't know what was the name of the object I can iterate on: https://twigfiddle.com/caaokq
hence, my thought of having a CSV that should be converted to an assoc-array that I can iterate over easily.
Well, you should be doing something like {"array": [1, 2, 3, 4] }
is you want to define a variable array
containing that array.
In your case you can replace array
by _context._parent
: https://twigfiddle.com/caaokq/2
The purpose of twigfiddle is to try and debug some twig code, I don't think I will integrate this feature.
I'm even going to remove lots of useless features such as "creation of public / private fiddles" or search filters etc in order to fit with that simple and pragmatic vision.
@ninsuo note that _context._parent
relies on an implementation detail of the {% for %}
tag here.
I tried to use dump() function to see the available context, but it wasn't working. any reasons why this is not available?
anyway, I understand your position and if this is not going to be included in the app,then this issue can be closed with a won't-fix resolution.
Hello
Yes dump is not available because it dumps html where twigfiddle renders text/plain.
I may implement it anyway (using the same kind of architecture than the profiler). Could you create a separate issue for this?
Thanks Alain
Le dim. 16 févr. 2020 à 10:44, Gabi Udrescu notifications@github.com a écrit :
I tried to use dump() function to see the available context, but it wasn't working. any reasons why this is not available?
anyway, I understand your position and if this is not going to be included in the app,then this issue can be closed with a won't-fix resolution.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/ninsuo/twigfiddle/issues/67?email_source=notifications&email_token=AA7VWRHMFAN53I4WIHP5OD3RDEDI5A5CNFSM4KKDO6SKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL4CCRY#issuecomment-586686791, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7VWRFU2LAAUYPJZ3XHUQTRDEDI5ANCNFSM4KKDO6SA .
the reason I wanted to use dump() function was to see what variables I have available in the twig env. instead of implementing a new dump function, I would rather list all variables in TwigFiddle UI. wdyt?
Rendering the context really depends on ... the context. If you're in the main Twig file, or in an included file, or within some tags... variables in the context may change.
Thus, using the {{ dump() }} function makes sense, and without recoding it. It's more changing the default location of its result.
I feel this fiddle should support CSV format as data format. how I plan to use this feature:
I can provide an implementation, if you want.