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

[Idea] Option for applying special formatting to certain columns, e.g., Pretty-printing JSON #388

Open
rdlugosz opened this issue Feb 23, 2022 · 1 comment

Comments

@rdlugosz
Copy link

Hi - Similar to the concept of smart_columns, or perhaps as an extension of them, how about a way to use a block of Ruby code to format the value of a column when displaying on the page?

The specific use case I have in mind for this is that I've got a result set that includes some JSON in one of the columns. It would be nice if there was a way I could apply some pretty printing (line breaks, indenting, etc) to that value before it's displayed in the table of results.

I suppose this would open up quite a few other options for customization, similar to how you can pass a block to a field in ActiveAdmin and do whatever you'd like with the value before it's displayed (e.g., adding links, styles, etc).

Thanks for considering!

@cianmce
Copy link
Contributor

cianmce commented Feb 23, 2022

Something similar to what is done with images could be done here app/helpers/blazer/base_helper.rb#L19
E.g. if it ends in json or yaml then attempt to pretty print and put it in a <pre> tag

Initial attempt in PR: #389

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

2 participants