Skip to main content

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"]),
            e.A(href="/")("Home"),
            e.Br(),
            e.A(href="/jinja2")("Jinja2"),
        )

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

Find demo and examples here

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

pyramid_htmldoom-0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

pyramid_htmldoom-0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pyramid_htmldoom-0.1.tar.gz.

File metadata

  • Download URL: pyramid_htmldoom-0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

File hashes

Hashes for pyramid_htmldoom-0.1.tar.gz
Algorithm Hash digest
SHA256 412e81206d6e796b110eef41bd8c63ed178fcdf4180999bdfe3f30c2c63876d0
MD5 e6377fceaa11970527d184e34ec3a717
BLAKE2b-256 e4f6f26ed993a359d0d7a92d6044b01124e24743f367b2c402f7f47750e25163

See more details on using hashes here.

Provenance

File details

Details for the file pyramid_htmldoom-0.1-py3-none-any.whl.

File metadata

  • Download URL: pyramid_htmldoom-0.1-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.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.5

File hashes

Hashes for pyramid_htmldoom-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c29fbff3a9dc95533b9ce2f3f234a24cb0331c7d9dac6fd0b63ab25585322c2b
MD5 bae94716659c849e52767073bd9ed3a8
BLAKE2b-256 b992752215e6711c317272af86fd5761bb6c24cc815b1287e0708503a015e911

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page