-
-
Notifications
You must be signed in to change notification settings - Fork 86
now with the coding hashbang at the top #2
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
Conversation
Added bootstrap option, converting table-like JSON (list of dicts with the same keys used for each dict) to multi-column html tables (before it would create a table for each row). This leads to a more readable display.
Awesome work man! Thanks for the patch @muellermichel |
@@ -23,6 +27,9 @@ def convert(self,**args): | |||
''' | |||
convert json Object to HTML Table format | |||
''' | |||
use_bootstrap = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would reduce the number of pass_ons for this variable if this can be made global just like a
, as use_bootstrap = False
. Please make it global and remove it as a parameter from each fn declaration, wherever you need to use use_bootstrap
just write global use_bootstrap
and then use it in next line. Hope that makes sense, right? 😄
After the mentioned changes, it's good to be merged. |
… to adhere to coding style
…n order to be able to use this tool with more flexibility
Thanks for your feedback. Alright, see my latest changes. I've used a global for the table styling options, also I went from 'use_bootstrap' to a generic 'table_attributes' in order to add any kind of classes and attributes to the table that you might want. example usage:
Together with this sorttable script has the nice benefit that all columns become sortable, see the screen. |
… not be displayed, unified markup code, improved error behavior -> removed try/except code in htmlConvertor that before would almost always blow up and hide any previous exceptions, instead added some safety to markup code
a=a+ '</td>' | ||
a=a+ '</tr>' | ||
continue | ||
a=a+ '<td>' + markup(v) + '</td>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if markup(v) return None
? I got some errors regarding this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, could you try now?
if 'table_attributes' in args: | ||
table_attributes = args['table_attributes'] | ||
else: | ||
table_attributes = "<table border=\"1\">" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check once, this will make the tag <table <table border="1">>
as you have used table_init_markup = "<table %s>" %(table_attributes) a=a+ table_init_markup
Please replace this with table_attributes = 'border="1"'
since we are just providing attributes as you mentioned earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn. sorry, on Japan time and it got late here, seems like I’ve potatoes on my eyes ;). amazingly it even rendered correctly in my browser.
On 02 Feb 2015, at 00:56, Varun Malhotra [email protected] wrote:
In json2html/jsonconv.py:
@@ -23,6 +23,12 @@ def convert(self,**args):
'''
convert json Object to HTML Table format
'''
global table_attributes
table_attributes = ''
if 'table_attributes' in args:
table_attributes = args['table_attributes']
else:
Please check once, this will make the tag <table > as you have used table_init_markup = "<table %s>" %(table_attributes)table_attributes = "<table border=\"1\">"
a=a+ table_init_markupPlease replace this with table_attributes = 'border="1"'
—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay! never mind 😄
now with the coding hashbang at the top
Thanks @muellermichel ! Really an Awesome work 👍 I have mentioned your contribution along with the example usage: https://github.com/softvar/json2html#readme |
Thanks man, appreciate it. See you around. |
How to apply that patch? |
@Brini06 Just install the latest of json2html, it would be included in that. |
No description provided.