示例#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"))
示例#2
0
文件: xhtml10.py 项目: scusack/tlhl
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"))
示例#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)
示例#4
0
文件: xhtml10.py 项目: scusack/tlhl
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)
示例#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'))
示例#6
0
文件: xhtml10.py 项目: scusack/tlhl
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"))
示例#7
0
文件: xhtml10.py 项目: scusack/tlhl
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)
示例#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)