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"))
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)
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'))
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"))
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)
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)