Created
May 5, 2020 18:49
-
-
Save jamescalam/4fd9cba3af72d5c701c66fc73f1a91af to your computer and use it in GitHub Desktop.
Dynamic creation of class buttons in HTML using Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # if length of classes is not zero | |
| if len(classes) > 0: | |
| # add class section start | |
| html += """ | |
| <h2>Classes</h2> | |
| <div class="row"> | |
| <!-- Class Buttons --> | |
| <div class="col-4"> | |
| <div class="list-group" id="list-mod" role="tablist"> | |
| """ | |
| # iterate through and add buttons/links | |
| for name in classes: | |
| html += f""" | |
| <a class="list-group-item list-group-item-action" id="label_{name}" data-toggle="list" href="#card_{name}" role="tab" aria-controls="home">{name}</a> | |
| """ | |
| # add end of button/links section | |
| html += """ | |
| </div> | |
| </div> | |
| <!-- Class Button Contents --> | |
| <div class="col-8"> | |
| <div class="tab-content" id="nav-tabContent"> | |
| """ | |
| # iterate through and add button contents | |
| for name in classes: | |
| html += f""" | |
| <div class="tab-pane fade" id="card_{name}" role="tabpanel" aria-labelledby="label_{name}"> | |
| <p> | |
| {classes[name]['description']} | |
| </p> | |
| <p> | |
| <a href="{module.lower().replace(" ", "_")}.{name}.html">Click here for documentation</a> | |
| </p> | |
| </div> | |
| """ | |
| # end class section | |
| html += f""" | |
| </div> | |
| </div> | |
| </div> | |
| """ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment