示例#1
0
def home():
    """Index page - without renderer"""
    return render(
        doctype("html"),
        e.html()(
            e.head()(e.title()("htmldoom rendering framework demo")),
            e.body()(
                e.h1()("Home page"),
                e.a(href="/jinja2")("Jinja2"),
                e.br(),
                e.a(href="/htmldoom")("htmldoom"),
            ),
        ),
    )
示例#2
0
def home(request):
    """Index page - without renderer"""
    return Response(
        render(
            doctype("html"),
            e.html()(
                e.head()(e.title()("Pyramid template engine demo")),
                e.body()(
                    e.h1()("Home page"),
                    e.a(href="/jinja2")("Jinja2"),
                    e.br(),
                    e.a(href="/htmldoom")("htmldoom"),
                ),
            ),
        ))
示例#3
0
from htmldoom import base as b
from htmldoom import elements as e
from htmldoom import render as _render
from htmldoom import renders


@renders(
    e.html(op="news")(
        e.head()(
            e.meta(name="referrer", content="origin"),
            e.meta(name="viewport",
                   content="width=device-width, initial-scale=1.0"),
            e.link(rel="stylesheet",
                   type_="text/css",
                   href="news.css?9UnLxU8WHV0ou3hRwndX"),
            e.link(rel="shortcut icon", href="favicon.ico"),
            e.link(rel="alternate",
                   type_="application/rss+xml",
                   title="RSS",
                   href="rss"),
            e.title()("Hacker News"),
        ),
        e.body()(e.center()(e.table(
            id_="hnmain",
            border="0",
            cellpadding="0",
            cellspacing="0",
            width="85%",
            bgcolor="#f6f6ef",
        )(
            e.tr()(e.td(bgcolor="#ff6600")(e.table(
示例#4
0
@renders(e.head()(
    "{title}",
    e.meta(
        name="description",
        content=(
            "Niteo is a decade old SaaS studio full of bright ideas, "
            "building smart   solutions that empower small businesses online."
        ),
    ),
    e.meta(charset="utf-8"),
    e.meta(name="viewport", content="width=device-width, initial-scale=1.0"),
    e.meta(name="twitter:card", content="summary_large_image"),
    e.meta(
        name="twitter:title",
        content="Niteo - Empowering small businesses online since '07",
    ),
    e.meta(
        name="twitter:description",
        content=(
            "Niteo is a decade old SaaS studio full of bright ideas, "
            "building smart   solutions that empower small businesses online."
        ),
    ),
    e.meta(name="twitter:site", content="@teamniteo"),
    e.meta(
        name="twitter:image",
        content="https://niteo.co/static_niteo_co/images/social/homepage.png",
    ),
    e.meta(property_="og:type", content="website"),
    e.meta(content="https://niteo.co/", property_="og:url"),
    e.meta(
        property_="og:title",
        content="Niteo - Empowering small businesses online since '07",
    ),
    e.meta(
        property_="og:description",
        content=
        "Niteo is a decade old SaaS studio full of bright ideas, building smart   solutions that empower small businesses online.",
    ),
    e.meta(
        property_="og:image",
        content="https://niteo.co/static_niteo_co/images/social/homepage.png",
    ),
    e.meta(property_="og:image:width", content="1200"),
    e.meta(property_="og:image:height", content="630"),
    e.link(
        rel="apple-touch-icon",
        sizes="180x180",
        href=
        "https://niteo.co/static_niteo_co/images/favicon/apple-touch-icon.png",
    ),
    e.link(
        rel="icon",
        type_="image/png",
        sizes="32x32",
        href=
        "https://niteo.co/static_niteo_co/images/favicon/favicon-32x32.png",
    ),
    e.link(
        rel="icon",
        type_="image/png",
        sizes="16x16",
        href=
        "https://niteo.co/static_niteo_co/images/favicon/favicon-16x16.png",
    ),
    e.link(
        rel="manifest",
        href="https://niteo.co/static_niteo_co/images/favicon/site.webmanifest",
    ),
    e.link(
        rel="mask-icon",
        href=
        "https://niteo.co/static_niteo_co/images/favicon/safari-pinned-tab.svg",
        color="#5bbad5",
    ),
    e.link(
        rel="shortcut icon",
        href="https://niteo.co/static_niteo_co/images/favicon/favicon.ico",
    ),
    e.meta(name="msapplication-TileColor", content="#00aba9"),
    e.meta(
        name="msapplication-config",
        content=
        "https://niteo.co/static_niteo_co/images/favicon/browserconfig.xml",
    ),
    e.meta(name="theme-color", content="#ffffff"),
    e.link(href="https://niteo.co/static_niteo_co/main.css", rel="stylesheet"),
    e.script(crossorigin="anonymous",
             src="/fanstatic/minisites/jquery-2.2.4.min.js"),
))
示例#5
0
from htmldoom import elements as e
from htmldoom import render as _render
from htmldoom import renders

doctype = _render(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) -> dict:
    return {
        "doctype": doctype,
        "title": title_renderer(doctitle=data["data"]),
        "body": body_renderer(data=data),
    }


def render(data):
    return render_document(data=data)