• function

register can.view.register

 

Register a templating language.

can.view.register(info)

Parameters

  1. info {Object}

    Information about the templating language.

    • plugin {String}

      The location of the templating language's plugin.

    • suffix {String}

      Files with this suffix will use this templating language's plugin by default.

    • renderer {function()}

      A function that returns a function that, given data, will render the template with that data. The renderer function receives the id of the template and the text of the template.

    • script {function()}

      A function that returns the string form of the processed template.

Registers a template engine to be used with view helpers and compression.

Example

can.View.register({
    suffix : "tmpl",
 plugin : "jquery/view/tmpl",
    renderer: function( id, text ) {
        return function(data){
            return jQuery.render( text, data );
        }
    },
    script: function( id, text ) {
        var tmpl = can.tmpl(text).toString();
        return "function(data){return ("+
            tmpl+
            ").call(jQuery, jQuery, data); }";
    }
})