Exemplo n.º 1
0
def css(params, printer):
    """
    Inline stylesheet.

    Usage:

    (css, "h1 {color:red;}", "h2 {color:purple;}")
    """
    attrs, params = canonicalise_params(params, attrs={"type": "text/css"})
    return (style, attrs, (raw, "\n", params, "\n"))
Exemplo n.º 2
0
def css(params, printer):
    """
    Inline stylesheet.

    Usage:

    (css, "h1 {color:red;}", "h2 {color:purple;}")
    """
    attrs, params = canonicalise_params(params, attrs={"type": "text/css"})
    return (style, attrs, (raw, "\n", params, "\n"))
Exemplo n.º 3
0
def js_include(params, printer):
    """
    Shorthand to include javascript via src link

    Usage:

    (js_include, "/assets/some.js")
    """
    attrs, src = canonicalise_params(params, length=1)
    attrs["src"] = src
    return (script, attrs)
Exemplo n.º 4
0
def js_include(params, printer):
    """
    Shorthand to include javascript via src link

    Usage:

    (js_include, "/assets/some.js")
    """
    attrs, src = canonicalise_params(params, length=1)
    attrs["src"] = src
    return (script, attrs)
Exemplo n.º 5
0
def js(params, printer):
    """
    Emits the contents (which are assumed to be valid javascript to
    the printer, wrapped in a CDATA section.

    Usage:
    (js, "var hello_world = function() { alert('hello world');};")

    or:

    (js,
    "var hello_world = function() { alert('hello world');};",
    "var hello_world2 = function() { alert('hello world2');};",
    )
    """
    attrs, params = canonicalise_params(params)
    return (script, attrs, (raw, '\n// <![CDATA[\n', params, '\n// ]]>\n'))
Exemplo n.º 6
0
def js(params, printer):
    """
    Emits the contents (which are assumed to be valid javascript to
    the printer, wrapped in a CDATA section.

    Usage:
    (js, "var hello_world = function() { alert('hello world');};")

    or:

    (js,
    "var hello_world = function() { alert('hello world');};",
    "var hello_world2 = function() { alert('hello world2');};",
    )
    """
    attrs, params = canonicalise_params(params)
    return (script, attrs, (raw, "\n// <![CDATA[\n", params, "\n// ]]>\n"))
Exemplo n.º 7
0
def css_include(params, printer):
    """
    Include link to an external CSS resource.

    Usage:

    (css_include, "some-stylesheet.css")

    or

    (css_include, {"media" : "print"}, "some-stylesheet.css")

    Only the first two parameters are considered significant.
    """

    attrs, href = canonicalise_params(
        params, attrs={"type": "text/css", "rel": "stylesheet", "media": "screen, projection"}, length=1
    )
    attrs["href"] = href
    return (link, attrs)
Exemplo n.º 8
0
def css_include(params, printer):
    """
    Include link to an external CSS resource.

    Usage:

    (css_include, "some-stylesheet.css")

    or

    (css_include, {"media" : "print"}, "some-stylesheet.css")

    Only the first two parameters are considered significant.
    """

    attrs, href = canonicalise_params(params,
                                      attrs={
                                          "type": "text/css",
                                          "rel": "stylesheet",
                                          "media": "screen, projection"
                                      },
                                      length=1)
    attrs['href'] = href
    return (link, attrs)