demo/amd/rjs/output/unified/marionette-build.js
function _createTemplateCache( templateProp, view, viewOptions ) {
        var $template, data, html,

            customLoader = Backbone.DeclarativeViews.custom.loadTemplate,
            defaultLoader = Backbone.DeclarativeViews.defaults.loadTemplate,
            modifiedDefaultLoader = defaultLoader !== loadTemplate,

            cacheId = templateProp;

        // Load the template
        try {
            $template = customLoader ? customLoader( templateProp, view, viewOptions ) : defaultLoader( templateProp, view, viewOptions );
        } catch ( err ) {
            // Rethrow and exit if the alarm has been raised deliberately, using an error type of Backbone.DeclarativeViews.
            if( _isDeclarativeViewsErrorType( err ) ) throw err;
            // Otherwise, continue without having fetched a template.
            $template = "";
        }

        if ( ( customLoader || modifiedDefaultLoader ) && $template !== "" && ! ( $template instanceof Backbone.$ ) ) {
            throw new CustomizationError( "Invalid return value. The " + ( customLoader ? "custom" : "default" ) + " loadTemplate function must return a jQuery instance, but it hasn't" );
        }

        // Create cache entry
        if ( $template.length ) {

            // Read the el-related data attributes of the template.
            data = _getDataAttributes( $template ) ;

            html = $template.html();

            templateCache[cacheId] = {
                html: html,
                compiled: _tryCompileTemplate( html, $template ),

                tagName: data.tagName,
                className: data.className,
                id: data.id,
                attributes: data.attributes,

                // Data store for plugins. Plugins should create their own namespace in the store, with the plugin name
                // as key.
                _pluginData: {}
            };

            events.trigger( "cacheEntry:create", templateCache[cacheId], templateProp, view, viewOptions );

        } else {
            templateCache[cacheId] = { invalid: true };
        }

        return templateCache[cacheId];
    }
function _createTemplateCache( templateProp, view, viewOptions ) {
        var $template, data, html,

            customLoader = Backbone.DeclarativeViews.custom.loadTemplate,
            defaultLoader = Backbone.DeclarativeViews.defaults.loadTemplate,
            modifiedDefaultLoader = defaultLoader !== loadTemplate,

            cacheId = templateProp;

        // Load the template
        try {
            $template = customLoader ? customLoader( templateProp, view, viewOptions ) : defaultLoader( templateProp, view, viewOptions );
        } catch ( err ) {
            // Rethrow and exit if the alarm has been raised deliberately, using an error type of Backbone.DeclarativeViews.
            if( _isDeclarativeViewsErrorType( err ) ) throw err;
            // Otherwise, continue without having fetched a template.
            $template = "";
        }

        if ( ( customLoader || modifiedDefaultLoader ) && $template !== "" && ! ( $template instanceof Backbone.$ ) ) {
            throw new CustomizationError( "Invalid return value. The " + ( customLoader ? "custom" : "default" ) + " loadTemplate function must return a jQuery instance, but it hasn't" );
        }

        // Create cache entry
        if ( $template.length ) {

            // Read the el-related data attributes of the template.
            data = _getDataAttributes( $template ) ;

            html = $template.html();

            templateCache[cacheId] = {
                html: html,
                compiled: _tryCompileTemplate( html, $template ),

                tagName: data.tagName,
                className: data.className,
                id: data.id,
                attributes: data.attributes,

                // Data store for plugins. Plugins should create their own namespace in the store, with the plugin name
                // as key.
                _pluginData: {}
            };

            events.trigger( "cacheEntry:create", templateCache[cacheId], templateProp, view, viewOptions );

        } else {
            templateCache[cacheId] = { invalid: true };
        }

        return templateCache[cacheId];
    }
Creates a cache entry for a given template property.

Returns the cached entry if creating it has succeeded. In case of failure, it returns the hash { invalid: true }.
It signals that the template has been processed, but that the returned hash, as well as the cache itself, does
not contain valid data for the template property.

The creation of a cache entry can fail if the template property is an empty string, or a selector which doesn't
match anything, or a string which jQuery can't process.

Uses a custom loader if specified, instead of loading the template with jQuery (default).

Events
------

The method fires the following event:

- cacheEntry:create

Fires only once per cache entry, when a valid cache entry is created. That may happen in the context of a view,
or with a global query.

The event handler receives the original cache entry. If the handler modifies the data, the modifications show
up in the returned result **and** alter the content in the cache.

If a valid cache entry can't be created (flagged as invalid), the event does NOT fire.

@param   {string}        templateProp   template selector, or raw template HTML, identifying the cache entry
@param   {Backbone.View} [view]         the view which requested the template
@param   {Object}        [viewOptions]  the options passed to the view during instantiation. For availability,
see getViewTemplateData()
@returns {CachedTemplateData|Uncacheable}