pyramid_htmldoom
htmldoom rendering library plugin for Pyramid
Usage
Install
pip install pyramid_htmldoom
Plug into Pyramid
app.py
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.view import view_config
@view_config(route_name="hello_htmldoom", renderer="templates.hello.py")
def hello_htmldoom_view(request):
"""htmldoom rendered view"""
return {"data": "Hello htmldoom"}
if __name__ == "__main__":
with Configurator() as config:
config.scan()
config.include("pyramid_htmldoom")
config.add_route("hello_htmldoom", "/")
app = config.make_wsgi_app()
server = make_server("localhost", 8080, app)
server.serve_forever()
templates/hello.py
from htmldoom import elements as e
from htmldoom import renders
from .layout import render_document
@renders(
e.body()(
e.h3()("{contents}"),
e.a(href="/")("Home"),
)
)
def render_body(data):
return {"contents": data["data"]}
def render(data):
return render_document(data, body_renderer=render_body)
templates/layout.py
from htmldoom import base as b
from htmldoom import elements as e
from htmldoom import renders
doctype = b.doctype("html")
@renders(e.title()("{doctitle}"))
def render_title(doctitle):
return {"doctitle": doctitle}
@renders(e.body()("{content}"))
def render_body(data):
raise NotImplementedError("You are trying to render a layout.")
@renders(doctype, e.html()(e.head()("{title}"), "{body}"))
def render_document(
data,
title_renderer=render_title,
body_renderer=render_body,
):
return {
"doctype": doctype,
"title": title_renderer(doctitle=data["data"]),
"body": body_renderer(data=data),
}
def render(data):
return render_document(data=data)
Examples
Deploy examples on heroku:
git push heroku $(git subtree split --prefix examples/2_hackernews master):master
Metadata
Release files for pyramid-htmldoom 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyramid_htmldoom-0.3.tar.gz | 3.3 kB | Without provenance | Details for pyramid_htmldoom-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyramid_htmldoom-0.3-py3-none-any.whl | Python 3 | none | any | Details for pyramid_htmldoom-0.3-py3-none-any.whl |
Total release size: 7.2 kB
Release files / pyramid_htmldoom-0.3.tar.gz
| Download URL | pyramid_htmldoom-0.3.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30cc4edca9487ee241f5d07b93f441c5728a50400f4b658715859eaedc04afa4
|
|
BLAKE2b-256 checksum How to use checksums |
516759adb9a853ae01cf4b3a8b7b70aa7fd5cbd43bf6115dd1b9fee78940c101
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
|
Release files / pyramid_htmldoom-0.3-py3-none-any.whl
| Download URL | pyramid_htmldoom-0.3-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a998d9eb3e84441f16299def3926c246f6b13ee17d103cdb1b2641ed2d0368ac
|
|
BLAKE2b-256 checksum How to use checksums |
0349739efb26ddb5696a071f88cf83ac18c070ba9a4227a59198286f27086bd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
|
Security for pyramid-htmldoom 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.