diff -r 322d0feea350 -r 89ef5ed3c48b src/cm/media/js/lib/yui/yui_3.10.3/build/handlebars-base/handlebars-base.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.10.3/build/handlebars-base/handlebars-base.js Tue Jul 16 14:29:46 2013 +0200 @@ -0,0 +1,446 @@ +/* +YUI 3.10.3 (build 2fb5187) +Copyright 2013 Yahoo! Inc. All rights reserved. +Licensed under the BSD License. +http://yuilibrary.com/license/ +*/ + +YUI.add('handlebars-base', function (Y, NAME) { + +/*! +Handlebars.js - Copyright (C) 2011 Yehuda Katz +https://raw.github.com/wycats/handlebars.js/master/LICENSE +*/ +// This file contains YUI-specific wrapper code and overrides for the +// handlebars-base module. + +/** +Handlebars is a simple template language inspired by Mustache. + +This is a YUI port of the original Handlebars project, which can be found at +. + +@module handlebars +@main handlebars +@since 3.5.0 +*/ + +/** +Provides basic Handlebars template rendering functionality. Use this module when +you only need to render pre-compiled templates. + +@module handlebars +@submodule handlebars-base +*/ + +/** +Handlebars is a simple template language inspired by Mustache. + +This is a YUI port of the original Handlebars project, which can be found at +. + +@class Handlebars +@since 3.5.0 +*/ +var Handlebars = Y.namespace('Handlebars'); +/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */ + +Handlebars.VERSION = "1.0.0-rc.4"; +Handlebars.COMPILER_REVISION = 3; + +Handlebars.REVISION_CHANGES = { + 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it + 2: '== 1.0.0-rc.3', + 3: '>= 1.0.0-rc.4' +}; + +Handlebars.helpers = {}; +Handlebars.partials = {}; + +var toString = Object.prototype.toString, + functionType = '[object Function]', + objectType = '[object Object]'; + +Handlebars.registerHelper = function(name, fn, inverse) { + if (toString.call(name) === objectType) { + if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); } + Handlebars.Utils.extend(this.helpers, name); + } else { + if (inverse) { fn.not = inverse; } + this.helpers[name] = fn; + } +}; + +Handlebars.registerPartial = function(name, str) { + if (toString.call(name) === objectType) { + Handlebars.Utils.extend(this.partials, name); + } else { + this.partials[name] = str; + } +}; + +Handlebars.registerHelper('helperMissing', function(arg) { + if(arguments.length === 2) { + return undefined; + } else { + throw new Error("Could not find property '" + arg + "'"); + } +}); + +Handlebars.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse || function() {}, fn = options.fn; + + var type = toString.call(context); + + if(type === functionType) { context = context.call(this); } + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if(type === "[object Array]") { + if(context.length > 0) { + return Handlebars.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + return fn(context); + } +}); + +Handlebars.K = function() {}; + +Handlebars.createFrame = Object.create || function(object) { + Handlebars.K.prototype = object; + var obj = new Handlebars.K(); + Handlebars.K.prototype = null; + return obj; +}; + +Handlebars.logger = { + DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, + + methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'}, + + // can be overridden in the host environment + log: function(level, obj) { + if (Handlebars.logger.level <= level) { + var method = Handlebars.logger.methodMap[level]; + if (typeof console !== 'undefined' && console[method]) { + console[method].call(console, obj); + } + } + } +}; + +Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); }; + +Handlebars.registerHelper('each', function(context, options) { + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + if (options.data) { + data = Handlebars.createFrame(options.data); + } + + if(context && typeof context === 'object') { + if(context instanceof Array){ + for(var j = context.length; i": ">", + '"': """, + "'": "'", + "`": "`" +}; + +var badChars = /[&<>"'`]/g; +var possible = /[&<>"'`]/; + +var escapeChar = function(chr) { + return escape[chr] || "&"; +}; + +Handlebars.Utils = { + extend: function(obj, value) { + for(var key in value) { + if(value.hasOwnProperty(key)) { + obj[key] = value[key]; + } + } + }, + + escapeExpression: function(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof Handlebars.SafeString) { + return string.toString(); + } else if (string == null || string === false) { + return ""; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = string.toString(); + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + }, + + isEmpty: function(value) { + if (!value && value !== 0) { + return true; + } else if(toString.call(value) === "[object Array]" && value.length === 0) { + return true; + } else { + return false; + } + } +}; +/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */ + +Handlebars.VM = { + template: function(templateSpec) { + // Just add water + var container = { + escapeExpression: Handlebars.Utils.escapeExpression, + invokePartial: Handlebars.VM.invokePartial, + programs: [], + program: function(i, fn, data) { + var programWrapper = this.programs[i]; + if(data) { + programWrapper = Handlebars.VM.program(i, fn, data); + } else if (!programWrapper) { + programWrapper = this.programs[i] = Handlebars.VM.program(i, fn); + } + return programWrapper; + }, + programWithDepth: Handlebars.VM.programWithDepth, + noop: Handlebars.VM.noop, + compilerInfo: null + }; + + return function(context, options) { + options = options || {}; + var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data); + + var compilerInfo = container.compilerInfo || [], + compilerRevision = compilerInfo[0] || 1, + currentRevision = Handlebars.COMPILER_REVISION; + + if (compilerRevision !== currentRevision) { + if (compilerRevision < currentRevision) { + var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision], + compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision]; + throw "Template was precompiled with an older version of Handlebars than the current runtime. "+ + "Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+")."; + } else { + // Use the embedded version info since the runtime doesn't know about this revision yet + throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+ + "Please update your runtime to a newer version ("+compilerInfo[1]+")."; + } + } + + return result; + }; + }, + + programWithDepth: function(i, fn, data /*, $depth */) { + var args = Array.prototype.slice.call(arguments, 3); + + var program = function(context, options) { + options = options || {}; + + return fn.apply(this, [context, options.data || data].concat(args)); + }; + program.program = i; + program.depth = args.length; + return program; + }, + program: function(i, fn, data) { + var program = function(context, options) { + options = options || {}; + + return fn(context, options.data || data); + }; + program.program = i; + program.depth = 0; + return program; + }, + noop: function() { return ""; }, + invokePartial: function(partial, name, context, helpers, partials, data) { + var options = { helpers: helpers, partials: partials, data: data }; + + if(partial === undefined) { + throw new Handlebars.Exception("The partial " + name + " could not be found"); + } else if(partial instanceof Function) { + return partial(context, options); + } else if (!Handlebars.compile) { + throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode"); + } else { + partials[name] = Handlebars.compile(partial, {data: data !== undefined}); + return partials[name](context, options); + } + } +}; + +Handlebars.template = Handlebars.VM.template; +// This file contains YUI-specific wrapper code and overrides for the +// handlebars-base module. + +Handlebars.VERSION += '-yui'; + +/** +Registers a helper function that will be made available to all templates. + +Helper functions receive the current template context as the `this` object, and +can also receive arguments passed by the template. + +@example + + Y.Handlebars.registerHelper('linkify', function () { + return '' + + Y.Escape.html(this.text) + ''; + }); + + var source = '
    {{#links}}
  • {{{linkify}}}
  • {{/links}}
'; + + Y.Handlebars.render(source, { + links: [ + {url: '/foo', text: 'Foo'}, + {url: '/bar', text: 'Bar'}, + {url: '/baz', text: 'Baz'} + ] + }); + +@method registerHelper +@param {String} name Name of this helper. +@param {Function} fn Helper function. +@param {Boolean} [inverse=false] If `true`, this helper will be considered an + "inverse" helper, like "unless". This means it will only be called if the + expression given in the template evaluates to a false or empty value. +*/ + +/** +Registers a partial that will be made available to all templates. + +A partial is another template that can be used to render part of a larger +template. For example, a website with a common header and footer across all its +pages might use a template for each page, which would call shared partials to +render the headers and footers. + +Partials may be specified as uncompiled template strings or as compiled template +functions. + +@example + + Y.Handlebars.registerPartial('header', '

{{title}}

'); + Y.Handlebars.registerPartial('footer', 'Copyright (c) 2011 by Me.'); + + var source = '{{> header}}

Mustaches are awesome!

{{> footer}}'; + + Y.Handlebars.render(source, {title: 'My Page About Mustaches'}); + +@method registerPartial +@param {String} name Name of this partial. +@param {Function|String} partial Template string or compiled template function. +*/ + +/** +Converts a precompiled template into a renderable template function. + +@example + + + + +@method template +@param {Function} template Precompiled Handlebars template function. +@return {Function} Compiled template function. +*/ + +// Alias for Y.Handlebars.template(), used by Y.Template. +Handlebars.revive = Handlebars.template; + +// Make Y.Template.Handlebars an alias for Y.Handlebars. +Y.namespace('Template').Handlebars = Handlebars; + + +}, '3.10.3', {"requires": []});