forked from datacontract/datacontract-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export data contract as HTML (datacontract#140)
resolves datacontract#15 Co-authored-by: jochen <[email protected]>
- Loading branch information
1 parent
2216e3f
commit 86f9c94
Showing
8 changed files
with
1,118 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from jinja2 import Environment, PackageLoader, select_autoescape | ||
|
||
from datacontract.model.data_contract_specification import \ | ||
DataContractSpecification | ||
|
||
|
||
def to_html(data_contract_spec: DataContractSpecification) -> str: | ||
# Load templates from templates folder | ||
file_loader = PackageLoader("datacontract", "templates") | ||
env = Environment(loader=file_loader, autoescape=select_autoescape( | ||
enabled_extensions=('html', 'xml'), | ||
default_for_string=True, | ||
)) | ||
|
||
# Load the required template | ||
template = env.get_template('datacontract.html') | ||
|
||
# Render the template with necessary data | ||
html_string = template.render(datacontract=data_contract_spec) | ||
|
||
return html_string |
Oops, something went wrong.