mozilla
Your Search Results

    Template:DekiScript:Web

    <% module.exports = buildAPI({
     
        // Insert a hyperlink.
        // [See also](http://developer.mindtouch.com/en/docs/DekiScript/Reference/DekiScript_Functions_and_Variables/Web.Link)
        link: function (uri, text, title, target) {
            var out = [
                '<a href="' + this.spacesToUnderscores(kuma.htmlEscape(uri)) + '"'
            ];
            if (title) {
                out.push(' title="' + kuma.htmlEscape(title) + '"');
            }
            if (target) {
                out.push(' target="' + kuma.htmlEscape(target) + '"');
            }
            out.push('>', kuma.htmlEscape(text || uri), '</a>');
            return out.join('');
        },
        
        // Convert source to HTML by optionally fetching and parsing it.
        // [See also](http://developer.mindtouch.com/en/docs/DekiScript/Reference/DekiScript_Functions_and_Variables/Web.Html)
        html: function (str) {
            // TODO: If str is an URL, fetch it and return that. Otherwise, this is just an echo function
            return str;
        },
        
        // Given a URL, convert all spaces to underscores. This lets us fix a bunch of places where templates
        // assume this is done automatically by the API, like MindTouch did.
        spacesToUnderscores: function(str) {
            var re1 = / /gi;
            var re2 = /%20/gi;
            str = str.replace(re1, "_");
            return str.replace(re2, "_");
        }
     
    }); %>
    Search for pages that use Template:DekiScript:Web to see example use cases and how many pages use this macro.

    Document Tags and Contributors

    Tags: 
    Contributors to this page: Sheppy, lmorchard
    Last updated by: Sheppy,