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

CSV format for data #67

Open
gabiudrescu opened this issue Jan 22, 2020 · 9 comments
Open

CSV format for data #67

gabiudrescu opened this issue Jan 22, 2020 · 9 comments

Comments

@gabiudrescu
Copy link

I feel this fiddle should support CSV format as data format. how I plan to use this feature:

  • create some queries in MySQL for non-technical people
  • allow them to export as CSV to do their thing in Excel
  • copy paste here and then render the twig to do stuff that Excel is bad at

I can provide an implementation, if you want.

@stof
Copy link
Contributor

stof commented Feb 12, 2020

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.

@gabiudrescu
Copy link
Author

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.

@stof
Copy link
Contributor

stof commented Feb 13, 2020

Well, you should be doing something like {"array": [1, 2, 3, 4] } is you want to define a variable array containing that array.

@ninsuo
Copy link
Owner

ninsuo commented Feb 13, 2020

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.

@stof
Copy link
Contributor

stof commented Feb 13, 2020

@ninsuo note that _context._parent relies on an implementation detail of the {% for %} tag here.

@gabiudrescu
Copy link
Author

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.

@ninsuo
Copy link
Owner

ninsuo commented Feb 16, 2020 via email

@gabiudrescu
Copy link
Author

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?

@ninsuo
Copy link
Owner

ninsuo commented Feb 16, 2020

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.

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

3 participants