Skip to content

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

Merged
merged 9 commits into from
Feb 1, 2015

Conversation

muellermichel
Copy link

No description provided.

Michel Müller added 2 commits January 31, 2015 21:47
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.
@softvar
Copy link
Owner

softvar commented Jan 31, 2015

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
Copy link
Owner

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? 😄

@softvar
Copy link
Owner

softvar commented Jan 31, 2015

After the mentioned changes, it's good to be merged.
I'll update the README file for the contribution and an example-usage after the merge.
+1

Michel Müller and others added 3 commits February 1, 2015 10:06
@muellermichel
Copy link
Author

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:

"<link href='/static/css/bootstrap.min.css' rel='stylesheet' media='screen'>" + \
"<script type='text/javascript' language='javascript' src='/static/js/sorttable.js'></script>" + \
json2html.convert(json=environments_json,table_attributes="class=\"sortable table table-condensed table-bordered table-hover\"")

Together with this sorttable script has the nice benefit that all columns become sortable, see the screen.

screen shot 2015-02-01 at 11 35 02

… 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>'
Copy link
Owner

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.

Copy link
Author

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\">"
Copy link
Owner

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.

Copy link
Author

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:
    
  •       table_attributes = "<table border=\"1\">"
    
    Please check once, this will make the tag <table > as you have used table_init_markup = "<table %s>" %(table_attributes)
    a=a+ table_init_markup

    Please replace this with table_attributes = 'border="1"'


    Reply to this email directly or view it on GitHub.

Copy link
Owner

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 😄

softvar added a commit that referenced this pull request Feb 1, 2015
now with the coding hashbang at the top
@softvar softvar merged commit 5cb8281 into softvar:master Feb 1, 2015
@softvar
Copy link
Owner

softvar commented Feb 1, 2015

Thanks @muellermichel !
I'm glad for your contribution.

Really an Awesome work 👍

I have mentioned your contribution along with the example usage: https://github.com/softvar/json2html#readme
Here's the updated version on PYPI: https://pypi.python.org/pypi/json2html/0.3

@muellermichel
Copy link
Author

Thanks man, appreciate it. See you around.

@Brini06
Copy link

Brini06 commented Oct 3, 2016

How to apply that patch?

@softvar
Copy link
Owner

softvar commented Oct 3, 2016

@Brini06 Just install the latest of json2html, it would be included in that.
Let me know if you run into issues.

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

Successfully merging this pull request may close these issues.

3 participants