Was this page helpful?

Web.Html

    Table of contents
    1. 1. Usage Restrictions
    2. 2. Parameters
    3. 3. Result
    4. 4. Samples
    web.Html(source : str, xpath : str, namespaces: map, ttl: num) : xml 

    Convert source to HTML by optionally fetching and parsing it.

    Usage Restrictions

    1.9.1 or later

    Parameters

    Name Type Description
    source str HTML source text or source uri
    xpath str (optional, default: none) xpath to value
    namespaces map (optional, default: none) XML namespace definitions
    ttl num (optional, range: 60 - 86400, default: 300) Caching durations in seconds (8.08 or later)

    Result

    The result of web.html depends on the combination of arguments provided.  If source is not a URI and xpath is omitted, web.html parses the source argument as a HTML fragment (see html fragment note below).  If source is not a URI and xpath is provided, then web.html parses the source argument as a HTML fragment and then applies the xpath expression (see xpath note below). If source is a URI and xpath is omitted, then web.html fetches the data from the URI and parses it as a HTML document.  If source is a URI and xpath is provided, then web.html fetches the data from the URI and applies the xpath expression.

    The HTML fragment does not need to be a complete HTML document. When parsed, it is automatically placed inside <html><body>source</body></html> context.  However, it MUST be structurally valid.  That is, all opened tags must also be closed.  For example, the following is NOT VALIDweb.html("<ul>").  When the HTML is fetched from a URI, it is expected to be a complete HTML document.

    Before the HTML result is returned, it is sanitized to remove any potential XSS vulnerabilities and HTML elements deemed unsafe.

    When applying the xpath expression, web.html returns only the first HTML node matched by the xpath expression.

    NOTE: all web.* functions are limited to reading at most 500KB of data from a URI.

    Samples

      Output

    To insert a bulleted list:

    {{ web.Html("<ul><li>item 1</li><li>item 2</li></ul>") }} 

    • item1
    • item 2

     

    Was this page helpful?
    Tag page
    Viewing 8 of 8 comments: view all
    Is there anyway to turn off the sanitize with web.html?
    Posted 14:56, 5 Nov 2008
    No, web.html always sanitizes the output.
    Posted 04:07, 20 Dec 2008
    How is web.html different than web.xml function?
    Posted 16:41, 29 Dec 2009
    @jonverve see response #4
    Posted 07:07, 30 Dec 2009
    I am desperate for an unsafe version of this function. Anyone have any ideas?
    Posted 08:19, 1 Apr 2010
    To be more specific... I have a string variable I want to render that has within it an anchor like...

    http://mywiki/index.php?title=mypage&action=comment&commentnum=7

    And web.html sanatizes it so the arguments are stripped. Uuuuuggghhhhhhh!
    Posted 08:21, 1 Apr 2010
    YES this is possible by using an inline call to a template e.g:

    deki:
    //bu is a value
    var bu1 = bu;
    //bu2 encloses it in quotes if bu1 is a string
    var bu2="'"..bu1.."'";
    var bu3='<a onclick="testfunction('..bu2..');return false;" href="#">testthis</a>';
    jswrite(bu3);
    -----------------------
    template:jswrite:

    <input type="hidden" value="{{($0)}}" id="temp0" /
    <script>
    document.write(DekiWiki.$("#temp0").val());
    </script> edited 05:21, 28 Jul 2010
    Posted 05:20, 28 Jul 2010
    I badly need an illustrative example of what the map of third parameter namespaces looks like. Can you supply one?
    Posted 00:43, 30 Nov 2010
    Viewing 8 of 8 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by