htmldoom rendering library plugin for Pyramid
Project description
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 .layout import Layout
class Template(Layout):
"""Hello view renderer"""
@property
def content(self):
return e.Div()(
e.H3()(self["data"]),
)
templates/layout.py
from htmldoom import elements as e
from htmldoom.layouts import BaseLayout
class Layout(BaseLayout):
@property
def title(self):
return e.Title()(self["data"])
@property
def body(self):
return e.Body()(e.Div(**{"id": "main"})(self.content))
@property
def content(self):
"""To be implemented by renderers."""
raise NotImplementedError()
Examples
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyramid_htmldoom-0.1.5.tar.gz
.
File metadata
- Download URL: pyramid_htmldoom-0.1.5.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7aa8cde3263b5b7b67dd083a1b3b609d9c297fee0e8b8a484f3693d09362f79 |
|
MD5 | 522abfec105d4c82a4555b25be763db9 |
|
BLAKE2b-256 | db6c2f5f724d220d58a24019e31af048f5f37c59b656eaf4dcce1f86d1b46cac |
Provenance
File details
Details for the file pyramid_htmldoom-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: pyramid_htmldoom-0.1.5-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64ecaa9ee8343ba7aeff1407f790b74135118bb8cba9aca2ec97bba51ad7e1f2 |
|
MD5 | 49079c4bb1713a8510ad0560de7e404e |
|
BLAKE2b-256 | a3680d63acfe3944792aa5f2d39cd3e674c3bedd220d898d93ce978dd0dd979c |