/usr/share/javascript/yui3/handlebars-base/handlebars-base.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
YUI.add('handlebars-base', function(Y) {
/*!
Handlebars.js - Copyright (C) 2011 Yehuda Katz
https://raw.github.com/wycats/handlebars.js/master/LICENSE
*/
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
// BEGIN(BROWSER)
/*jshint eqnull:true*/
var Handlebars = {};
Handlebars.VERSION = "1.0.beta.5";
Handlebars.helpers = {};
Handlebars.partials = {};
Handlebars.registerHelper = function(name, fn, inverse) {
if(inverse) { fn.not = inverse; }
this.helpers[name] = fn;
};
Handlebars.registerPartial = function(name, str) {
this.partials[name] = str;
};
Handlebars.registerHelper('helperMissing', function(arg) {
if(arguments.length === 2) {
return undefined;
} else {
throw new Error("Could not find property '" + arg + "'");
}
});
var toString = Object.prototype.toString, functionType = "[object Function]";
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
var inverse = options.inverse || function() {}, fn = options.fn;
var ret = "";
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) {
for(var i=0, j=context.length; i<j; i++) {
ret = ret + fn(context[i]);
}
} else {
ret = inverse(this);
}
return ret;
} else {
return fn(context);
}
});
Handlebars.registerHelper('each', function(context, options) {
var fn = options.fn, inverse = options.inverse;
var ret = "";
if(context && context.length > 0) {
for(var i=0, j=context.length; i<j; i++) {
ret = ret + fn(context[i]);
}
} else {
ret = inverse(this);
}
return ret;
});
Handlebars.registerHelper('if', function(context, options) {
var type = toString.call(context);
if(type === functionType) { context = context.call(this); }
if(!context || Handlebars.Utils.isEmpty(context)) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
Handlebars.registerHelper('unless', function(context, options) {
var fn = options.fn, inverse = options.inverse;
options.fn = inverse;
options.inverse = fn;
return Handlebars.helpers['if'].call(this, context, options);
});
Handlebars.registerHelper('with', function(context, options) {
return options.fn(context);
});
Handlebars.registerHelper('log', function(context) {
Handlebars.log(context);
});
// END(BROWSER)
// This file provides a YUI-specific implementation of Handlebars' lib/utils.js
// file. Handlebars unfortunately creates enclosed references to its utils, so
// we have to maintain a complete fork of this file rather than just overriding
// specific parts.
var Lang = Y.Lang;
Handlebars.Exception = function (message) {
var error = Error.prototype.constructor.apply(this, arguments),
key;
for (key in error) {
if (error.hasOwnProperty(key)) {
this[key] = error[key];
}
}
this.message = error.message;
};
Handlebars.Exception.prototype = new Error();
Handlebars.SafeString = function (string) {
this.string = string;
};
Handlebars.SafeString.prototype.toString = function () {
return this.string.toString();
};
Handlebars.Utils = {
escapeExpression: function (string) {
// Skip escaping for empty strings.
if (string === '') {
return string;
}
// Don't escape SafeStrings, since they're already (presumed to be)
// safe.
if (string instanceof Handlebars.SafeString) {
return string.toString();
} else if (string === false || !Lang.isValue(string)) {
return '';
}
// Unlike Handlebars' escaping implementation, Y.Escape.html() will
// double-escape existing & entities. This seems much less
// surprising than avoiding double-escaping, especially since
// a lack of double-escaping would make it impossible to use Handlebars
// for things like displaying escaped code snippets.
return Y.Escape.html(string);
},
isEmpty: function (value) {
if (value === false
|| !Lang.isValue(value)
|| (Lang.isArray(value) && !value.length)) {
return true;
}
return false;
}
};
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */
// BEGIN(BROWSER)
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) {
return Handlebars.VM.program(fn, data);
} else if(programWrapper) {
return programWrapper;
} else {
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
return programWrapper;
}
},
programWithDepth: Handlebars.VM.programWithDepth,
noop: Handlebars.VM.noop
};
return function(context, options) {
options = options || {};
return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
};
},
programWithDepth: function(fn, data, $depth) {
var args = Array.prototype.slice.call(arguments, 2);
return function(context, options) {
options = options || {};
return fn.apply(this, [context, options.data || data].concat(args));
};
},
program: function(fn, data) {
return function(context, options) {
options = options || {};
return fn(context, options.data || data);
};
},
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);
return partials[name](context, options);
}
}
};
Handlebars.template = Handlebars.VM.template;
// END(BROWSER)
// 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
<https://github.com/wycats/handlebars.js>.
@module handlebars
@main handlebars
*/
/**
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
<https://github.com/wycats/handlebars.js>.
@class Handlebars
*/
Y.Handlebars = Handlebars;
Handlebars.VERSION += '-yui';
// The rest of this file is just API docs for methods defined in Handlebars
// itself.
/**
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 '<a href="' + Y.Escape.html(this.url) + '">' +
Y.Escape.html(this.text) + '</a>';
});
var source = '<ul>{{#each links}}<li>{{linkify}}</li>{{/each}}</ul>';
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', '<h1>{{title}}</h1>');
Y.Handlebars.registerPartial('footer', 'Copyright (c) 2011 by Me.');
var source = '{{> header}} <p>Mustaches are awesome!</p> {{> 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
<script src="precompiled-template.js"></script>
<script>
YUI().use('handlebars-base', function (Y) {
// Convert the precompiled template function into a renderable template
// function.
var template = Y.Handlebars.template(precompiledTemplate);
// Render it.
template({pie: 'Pumpkin'});
});
</script>
@method template
@param {Function} template Precompiled Handlebars template function.
@return {Function} Compiled template function.
*/
}, '3.5.1' ,{requires:['escape']});
|