parent
5cfe2c0186
commit
4d23b2cac3
@ -1,185 +0,0 @@
|
|||||||
module.exports = function (grunt) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var outputRoot = '_output/';
|
|
||||||
var outputDir = outputRoot +'UI/';
|
|
||||||
var srcRoot = 'src/UI/';
|
|
||||||
var srcContent = srcRoot + 'Content/';
|
|
||||||
var destContent = outputDir + 'Content/';
|
|
||||||
|
|
||||||
grunt.initConfig({
|
|
||||||
|
|
||||||
pkg: grunt.file.readJSON('package.json'),
|
|
||||||
|
|
||||||
clean: {
|
|
||||||
output: outputDir,
|
|
||||||
scripts: [ outputDir + '/**.js','!_output/UI/**/templates.js']
|
|
||||||
},
|
|
||||||
|
|
||||||
less : {
|
|
||||||
|
|
||||||
options:{
|
|
||||||
dumpLineNumbers : 'false',
|
|
||||||
compress : true,
|
|
||||||
yuicompress : false,
|
|
||||||
ieCompat : true,
|
|
||||||
strictImports : true
|
|
||||||
},
|
|
||||||
|
|
||||||
bootstrap: {
|
|
||||||
src : srcContent + 'bootstrap.less',
|
|
||||||
dest: destContent + 'bootstrap.css'
|
|
||||||
},
|
|
||||||
general : {
|
|
||||||
cwd : srcRoot,
|
|
||||||
expand : true,
|
|
||||||
src :[
|
|
||||||
'Content/theme.less',
|
|
||||||
'Content/overrides.less',
|
|
||||||
'Series/series.less',
|
|
||||||
'History/history.less',
|
|
||||||
'AddSeries/addSeries.less',
|
|
||||||
'Calendar/calendar.less',
|
|
||||||
'Cells/cells.less',
|
|
||||||
'Settings/settings.less',
|
|
||||||
'System/Logs/logs.less',
|
|
||||||
'System/Update/update.less'
|
|
||||||
],
|
|
||||||
dest : outputDir,
|
|
||||||
ext: '.css'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
handlebars: {
|
|
||||||
options: {
|
|
||||||
namespace : 'T',
|
|
||||||
partialRegex: /Partial.hbs/,
|
|
||||||
wrapped : true,
|
|
||||||
amd : true,
|
|
||||||
processName: function (fileName) {
|
|
||||||
return fileName
|
|
||||||
.replace(srcRoot, '')
|
|
||||||
.replace('.hbs', '')
|
|
||||||
.toLowerCase();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
files : {
|
|
||||||
src : [ srcRoot + '**/*Template.hbs', srcRoot + '**/*Partial.hbs'],
|
|
||||||
dest: outputDir + 'templates.js'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
copy: {
|
|
||||||
content: {
|
|
||||||
cwd : srcRoot,
|
|
||||||
expand: true,
|
|
||||||
src : [
|
|
||||||
'index.html',
|
|
||||||
'**/*.css',
|
|
||||||
'**/*.png',
|
|
||||||
'**/*.jpg',
|
|
||||||
'**/*.ico',
|
|
||||||
'**/*.swf',
|
|
||||||
'**/FontAwesome/*.*',
|
|
||||||
'**/fonts/*.*'
|
|
||||||
],
|
|
||||||
dest : outputDir
|
|
||||||
},
|
|
||||||
scripts: {
|
|
||||||
cwd : srcRoot,
|
|
||||||
expand: true,
|
|
||||||
src : [
|
|
||||||
'**/*.js'
|
|
||||||
],
|
|
||||||
dest : outputDir
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
jshint: {
|
|
||||||
options: {
|
|
||||||
'-W030': false,
|
|
||||||
'-W064': false,
|
|
||||||
'-W097': false,
|
|
||||||
'-W100': false,
|
|
||||||
'undef': true,
|
|
||||||
'globals': {
|
|
||||||
'require': true,
|
|
||||||
'define': true,
|
|
||||||
'window': true,
|
|
||||||
'document': true,
|
|
||||||
'console': true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
all: [
|
|
||||||
srcRoot + '**/*.js',
|
|
||||||
'!**/JsLibraries/*.js'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
requirejs: {
|
|
||||||
compile:{
|
|
||||||
options: {
|
|
||||||
mainConfigFile: 'src/UI/app.js',
|
|
||||||
fileExclusionRegExp: /^.*\.(?!js$)[^.]+$/,
|
|
||||||
preserveLicenseComments: false,
|
|
||||||
dir: outputDir,
|
|
||||||
optimize: 'none',
|
|
||||||
removeCombined: true,
|
|
||||||
inlineText: false,
|
|
||||||
keepBuildDir : true,
|
|
||||||
modules: [{
|
|
||||||
name: 'app',
|
|
||||||
exclude: ['templates.js']
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
options: {
|
|
||||||
nospawn: false
|
|
||||||
},
|
|
||||||
bootstrap : {
|
|
||||||
files: [ srcContent + 'Bootstrap/**', srcContent + 'FontAwesome/**', srcContent + 'bootstrap.less'],
|
|
||||||
tasks: ['less:bootstrap','less:general']
|
|
||||||
},
|
|
||||||
generalLess: {
|
|
||||||
files: [ srcRoot + '**/*.less', '!**/Bootstrap/**', '!**/FontAwesome/**', '!' + srcContent + '/bootstrap.less'],
|
|
||||||
tasks: ['less:general']
|
|
||||||
},
|
|
||||||
handlebars : {
|
|
||||||
files: '<%= handlebars.files.src %>',
|
|
||||||
tasks: ['handlebars']
|
|
||||||
},
|
|
||||||
content : {
|
|
||||||
files: [
|
|
||||||
srcRoot + '**/index.html',
|
|
||||||
srcRoot + '**/*.css',
|
|
||||||
srcRoot + '**/*.png',
|
|
||||||
srcRoot + '**/*.jpg',
|
|
||||||
srcRoot + '**/*.ico',
|
|
||||||
srcRoot + '**/FontAwesome/*.*',
|
|
||||||
srcRoot + '**/fonts/*.*'
|
|
||||||
],
|
|
||||||
tasks: ['copy:content']
|
|
||||||
},
|
|
||||||
scripts: {
|
|
||||||
files: '<%= copy.scripts.cwd %><%= copy.scripts.src %>',
|
|
||||||
tasks: ['copy:scripts']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-handlebars');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-less');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
|
||||||
grunt.loadNpmTasks('grunt-notify');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-requirejs');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
||||||
|
|
||||||
grunt.registerTask('package', ['clean:output', 'jshint', 'handlebars', 'copy', 'less']);
|
|
||||||
grunt.registerTask('packagerjs', ['clean:output','jshint', 'handlebars', 'requirejs', 'copy:content', 'less']);
|
|
||||||
grunt.registerTask('default', ['package', 'watch']);
|
|
||||||
};
|
|
@ -0,0 +1,13 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var runSequence = require('run-sequence');
|
||||||
|
|
||||||
|
require('./clean');
|
||||||
|
require('./requirejs');
|
||||||
|
require('./less');
|
||||||
|
require('./handlebars');
|
||||||
|
require('./copy');
|
||||||
|
|
||||||
|
gulp.task('build', function () {
|
||||||
|
return runSequence('clean',
|
||||||
|
['requireJs', 'less', 'handlebars', 'copyIndex', 'copyContent']);
|
||||||
|
});
|
@ -0,0 +1,9 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var clean = require('gulp-clean');
|
||||||
|
|
||||||
|
var paths = require('./paths');
|
||||||
|
|
||||||
|
gulp.task('clean', function () {
|
||||||
|
return gulp.src(paths.dest.root, {read: false})
|
||||||
|
.pipe(clean());
|
||||||
|
});
|
@ -0,0 +1,22 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var print = require('gulp-print');
|
||||||
|
var cache = require('gulp-cached');
|
||||||
|
|
||||||
|
var paths = require('./paths.js');
|
||||||
|
|
||||||
|
gulp.task('copyJs', function () {
|
||||||
|
return gulp.src([paths.src.scripts])
|
||||||
|
.pipe(cache())
|
||||||
|
.pipe(gulp.dest(paths.dest.root));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('copyIndex', function () {
|
||||||
|
return gulp.src(paths.src.index)
|
||||||
|
.pipe(cache())
|
||||||
|
.pipe(gulp.dest(paths.dest.root));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('copyContent', function () {
|
||||||
|
return gulp.src([paths.src.content + '**/*.*', '!**/*.less'])
|
||||||
|
.pipe(gulp.dest(paths.dest.content));
|
||||||
|
});
|
@ -0,0 +1,11 @@
|
|||||||
|
require('./watch.js');
|
||||||
|
require('./build.js');
|
||||||
|
require('./clean.js');
|
||||||
|
require('./requirejs.js');
|
||||||
|
require('./jshint.js');
|
||||||
|
require('./handlebars.js');
|
||||||
|
require('./copy.js');
|
||||||
|
require('./less.js');
|
||||||
|
require('./stripBom.js');
|
||||||
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var handlebars = require('gulp-handlebars');
|
||||||
|
var declare = require('gulp-declare');
|
||||||
|
var concat = require('gulp-concat');
|
||||||
|
var wrapAmd = require('gulp-wrap-amd');
|
||||||
|
var wrap = require("gulp-wrap");
|
||||||
|
var path = require('path');
|
||||||
|
var streamqueue = require('streamqueue');
|
||||||
|
|
||||||
|
var paths = require('./paths.js');
|
||||||
|
var bom = require('./pipelines/gulp-bom.js');
|
||||||
|
|
||||||
|
gulp.task('handlebars', function () {
|
||||||
|
|
||||||
|
var coreStream = gulp.src([paths.src.templates, '!*/**/*Partial.*'])
|
||||||
|
.pipe(bom())
|
||||||
|
.pipe(handlebars())
|
||||||
|
.pipe(declare({
|
||||||
|
namespace: 'T',
|
||||||
|
noRedeclare: true,
|
||||||
|
processName: function (filePath) {
|
||||||
|
|
||||||
|
filePath = path.relative(paths.src.root, filePath);
|
||||||
|
|
||||||
|
return filePath.replace(/\\/g, '/')
|
||||||
|
.toLocaleLowerCase()
|
||||||
|
.replace('template', '')
|
||||||
|
.replace('.js', '');
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
var partialStream = gulp.src([paths.src.partials])
|
||||||
|
.pipe(bom())
|
||||||
|
.pipe(handlebars())
|
||||||
|
.pipe(wrap('Handlebars.template(<%= contents %>)'))
|
||||||
|
.pipe(wrap('Handlebars.registerPartial(<%= processPartialName(file.relative) %>, <%= contents %>)', {}, {
|
||||||
|
imports: {
|
||||||
|
processPartialName: function (fileName) {
|
||||||
|
return JSON.stringify(
|
||||||
|
path.basename(fileName, '.js')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
return streamqueue({ objectMode: true },
|
||||||
|
partialStream,
|
||||||
|
coreStream
|
||||||
|
).pipe(concat('templates.js'))
|
||||||
|
.pipe(wrapAmd({
|
||||||
|
deps: ['handlebars'],
|
||||||
|
params: ['Handlebars'],
|
||||||
|
exports: 'this["T"]'
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest(paths.dest.root));
|
||||||
|
});
|
@ -0,0 +1,26 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var jshint = require('gulp-jshint');
|
||||||
|
var stylish = require('jshint-stylish');
|
||||||
|
var cache = require('gulp-cached');
|
||||||
|
var paths = require('./paths.js');
|
||||||
|
|
||||||
|
|
||||||
|
gulp.task('jshint', function () {
|
||||||
|
return gulp.src([paths.src.scripts, paths.src.exclude.libs])
|
||||||
|
.pipe(cache())
|
||||||
|
.pipe(jshint({
|
||||||
|
'-W030': false,
|
||||||
|
'-W064': false,
|
||||||
|
'-W097': false,
|
||||||
|
'-W100': false,
|
||||||
|
'undef': true,
|
||||||
|
'globals': {
|
||||||
|
'require': true,
|
||||||
|
'define': true,
|
||||||
|
'window': true,
|
||||||
|
'document': true,
|
||||||
|
'console': true
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.pipe(jshint.reporter(stylish));
|
||||||
|
});
|
@ -0,0 +1,30 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var less = require('gulp-less');
|
||||||
|
var print = require('gulp-print');
|
||||||
|
|
||||||
|
var paths = require('./paths');
|
||||||
|
|
||||||
|
gulp.task('less', function () {
|
||||||
|
return gulp.src([
|
||||||
|
paths.src.content + 'bootstrap.less',
|
||||||
|
paths.src.content + 'theme.less',
|
||||||
|
paths.src.content + 'overrides.less',
|
||||||
|
paths.src.root + 'Series/series.less',
|
||||||
|
paths.src.root + 'History/history.less',
|
||||||
|
paths.src.root + 'AddSeries/addSeries.less',
|
||||||
|
paths.src.root + 'Calendar/calendar.less',
|
||||||
|
paths.src.root + 'Cells/cells.less',
|
||||||
|
paths.src.root + 'Settings/settings.less',
|
||||||
|
paths.src.root + 'System/Logs/logs.less',
|
||||||
|
paths.src.root + 'System/Update/update.less',
|
||||||
|
])
|
||||||
|
.pipe(print())
|
||||||
|
.pipe(less({
|
||||||
|
dumpLineNumbers: 'false',
|
||||||
|
compress: true,
|
||||||
|
yuicompress: true,
|
||||||
|
ieCompat: true,
|
||||||
|
strictImports: true
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest(paths.dest.content));
|
||||||
|
});
|
@ -0,0 +1,26 @@
|
|||||||
|
module.exports = {
|
||||||
|
js: [
|
||||||
|
'./app/**/*.js',
|
||||||
|
'./src/**/*.js',
|
||||||
|
'!./**/libs/**',
|
||||||
|
'!./**/vendor/**',
|
||||||
|
'!./**/templates.js'
|
||||||
|
],
|
||||||
|
|
||||||
|
src: {
|
||||||
|
root: './src/UI/',
|
||||||
|
templates: './src/UI/**/*.hbs',
|
||||||
|
index: './src/UI/index.html',
|
||||||
|
partials: './src/UI/**/*Partial.hbs',
|
||||||
|
scripts: './src/UI/**/*.js',
|
||||||
|
less: ['./src/UI/**/*.less'],
|
||||||
|
content: './src/UI/Content/',
|
||||||
|
exclude :{
|
||||||
|
libs:'!./src/UI/JsLibraries/**'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dest: {
|
||||||
|
root: './_output/UI/',
|
||||||
|
content: './_output/UI/Content/'
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,4 @@
|
|||||||
|
var replace = require('gulp-replace');
|
||||||
|
module.exports = function() {
|
||||||
|
return replace(/^\uFEFF/, '');
|
||||||
|
};
|
@ -0,0 +1,32 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var requirejs = require('requirejs');
|
||||||
|
var paths = require('./paths');
|
||||||
|
|
||||||
|
require('./handlebars.js');
|
||||||
|
require('./jshint.js');
|
||||||
|
|
||||||
|
|
||||||
|
gulp.task('requireJs', ['jshint'], function (cb) {
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
mainConfigFile: 'src/UI/app.js',
|
||||||
|
fileExclusionRegExp: /^.*\.(?!js$)[^.]+$/,
|
||||||
|
preserveLicenseComments: false,
|
||||||
|
dir: paths.dest.root,
|
||||||
|
optimize: 'none',
|
||||||
|
removeCombined: true,
|
||||||
|
inlineText: false,
|
||||||
|
keepBuildDir: true,
|
||||||
|
modules: [
|
||||||
|
{
|
||||||
|
name: 'app',
|
||||||
|
exclude: ['templates.js']
|
||||||
|
}
|
||||||
|
]};
|
||||||
|
|
||||||
|
requirejs.optimize(config, function (buildResponse) {
|
||||||
|
console.log(buildResponse);
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,25 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
var paths = require('./paths.js');
|
||||||
|
var bom = require('./pipelines/gulp-bom.js');
|
||||||
|
var gulpPrint = require('gulp-print');
|
||||||
|
|
||||||
|
|
||||||
|
var stripBom = function (dest) {
|
||||||
|
gulp.src([paths.src.root, paths.src.exclude.libs])
|
||||||
|
.pipe(bom())
|
||||||
|
.pipe(gulpPrint(function (filepath) {
|
||||||
|
return "booming: " + filepath;
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest(dest));
|
||||||
|
|
||||||
|
gulp.src(paths.src.templates)
|
||||||
|
.pipe(bom())
|
||||||
|
.pipe(gulpPrint(function (filepath) {
|
||||||
|
return "booming: " + filepath;
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest(dest));
|
||||||
|
};
|
||||||
|
|
||||||
|
gulp.task('stripBom', function () {
|
||||||
|
stripBom(paths.src.root);
|
||||||
|
});
|
@ -0,0 +1,30 @@
|
|||||||
|
var gulp = require('gulp');
|
||||||
|
//var livereload = require('gulp-livereload');
|
||||||
|
|
||||||
|
|
||||||
|
var paths = require('./paths.js');
|
||||||
|
|
||||||
|
require('./jshint.js');
|
||||||
|
require('./handlebars.js');
|
||||||
|
require('./less.js');
|
||||||
|
require('./copy.js');
|
||||||
|
|
||||||
|
|
||||||
|
gulp.task('watch', ['jshint', 'handlebars', 'less', 'copyJs'], function () {
|
||||||
|
gulp.watch([paths.src.scripts, paths.src.exclude.libs], ['jshint', 'copyJs']);
|
||||||
|
gulp.watch(paths.src.templates, ['handlebars']);
|
||||||
|
gulp.watch([paths.src.less, paths.src.exclude.libs], ['less']);
|
||||||
|
gulp.watch([paths.src.index], ['copyIndex']);
|
||||||
|
gulp.watch([paths.src.content + '**/*.*', '!**/*.less'], ['copyContent']);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('liveReload', ['jshint', 'handlebars', 'less', 'copyJs'], function () {
|
||||||
|
var server = livereload();
|
||||||
|
gulp.watch([
|
||||||
|
'app/**/*.js',
|
||||||
|
'app/**/*.css',
|
||||||
|
'app/index.html'
|
||||||
|
]).on('change', function (file) {
|
||||||
|
server.changed(file.path);
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1 @@
|
|||||||
|
require('./gulp/gulpfile.js');
|
@ -1,374 +1,530 @@
|
|||||||
/*
|
/*!
|
||||||
|
|
||||||
Copyright (C) 2011 by Yehuda Katz
|
handlebars v1.3.0
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Copyright (C) 2011 by Yehuda Katz
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
in the Software without restriction, including without limitation the rights
|
||||||
furnished to do so, subject to the following conditions:
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
The above copyright notice and this permission notice shall be included in
|
furnished to do so, subject to the following conditions:
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
all copies or substantial portions of the Software.
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
THE SOFTWARE.
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
@license
|
THE SOFTWARE.
|
||||||
*/
|
|
||||||
|
@license
|
||||||
// lib/handlebars/browser-prefix.js
|
*/
|
||||||
(function(undefined) {
|
/* exported Handlebars */
|
||||||
var Handlebars = {};
|
var Handlebars = (function() {
|
||||||
;
|
// handlebars/safe-string.js
|
||||||
// lib/handlebars/base.js
|
var __module3__ = (function() {
|
||||||
|
"use strict";
|
||||||
Handlebars.VERSION = "1.0.0";
|
var __exports__;
|
||||||
Handlebars.COMPILER_REVISION = 4;
|
// Build out our basic SafeString type
|
||||||
|
function SafeString(string) {
|
||||||
Handlebars.REVISION_CHANGES = {
|
this.string = string;
|
||||||
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',
|
|
||||||
4: '>= 1.0.0'
|
|
||||||
};
|
|
||||||
|
|
||||||
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("Missing helper: '" + 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;
|
|
||||||
|
|
||||||
var type = toString.call(context);
|
|
||||||
if(type === functionType) { context = context.call(this); }
|
|
||||||
|
|
||||||
if (options.data) {
|
|
||||||
data = Handlebars.createFrame(options.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(context && typeof context === 'object') {
|
|
||||||
if(context instanceof Array){
|
|
||||||
for(var j = context.length; i<j; i++) {
|
|
||||||
if (data) { data.index = i; }
|
|
||||||
ret = ret + fn(context[i], { data: data });
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(var key in context) {
|
|
||||||
if(context.hasOwnProperty(key)) {
|
|
||||||
if(data) { data.key = key; }
|
|
||||||
ret = ret + fn(context[key], {data: data});
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
SafeString.prototype.toString = function() {
|
||||||
}
|
return "" + this.string;
|
||||||
|
};
|
||||||
if(i === 0){
|
|
||||||
ret = inverse(this);
|
__exports__ = SafeString;
|
||||||
}
|
return __exports__;
|
||||||
|
})();
|
||||||
return ret;
|
|
||||||
});
|
// handlebars/utils.js
|
||||||
|
var __module2__ = (function(__dependency1__) {
|
||||||
Handlebars.registerHelper('if', function(conditional, options) {
|
"use strict";
|
||||||
var type = toString.call(conditional);
|
var __exports__ = {};
|
||||||
if(type === functionType) { conditional = conditional.call(this); }
|
/*jshint -W004 */
|
||||||
|
var SafeString = __dependency1__;
|
||||||
if(!conditional || Handlebars.Utils.isEmpty(conditional)) {
|
|
||||||
return options.inverse(this);
|
var escape = {
|
||||||
} else {
|
"&": "&",
|
||||||
return options.fn(this);
|
"<": "<",
|
||||||
}
|
">": ">",
|
||||||
});
|
'"': """,
|
||||||
|
"'": "'",
|
||||||
Handlebars.registerHelper('unless', function(conditional, options) {
|
"`": "`"
|
||||||
return Handlebars.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn});
|
};
|
||||||
});
|
|
||||||
|
var badChars = /[&<>"'`]/g;
|
||||||
Handlebars.registerHelper('with', function(context, options) {
|
var possible = /[&<>"'`]/;
|
||||||
var type = toString.call(context);
|
|
||||||
if(type === functionType) { context = context.call(this); }
|
function escapeChar(chr) {
|
||||||
|
return escape[chr] || "&";
|
||||||
if (!Handlebars.Utils.isEmpty(context)) return options.fn(context);
|
}
|
||||||
});
|
|
||||||
|
function extend(obj, value) {
|
||||||
Handlebars.registerHelper('log', function(context, options) {
|
for(var key in value) {
|
||||||
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
|
if(Object.prototype.hasOwnProperty.call(value, key)) {
|
||||||
Handlebars.log(level, context);
|
obj[key] = value[key];
|
||||||
});
|
}
|
||||||
;
|
}
|
||||||
// lib/handlebars/utils.js
|
}
|
||||||
|
|
||||||
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
|
__exports__.extend = extend;var toString = Object.prototype.toString;
|
||||||
|
__exports__.toString = toString;
|
||||||
Handlebars.Exception = function(message) {
|
// Sourced from lodash
|
||||||
var tmp = Error.prototype.constructor.apply(this, arguments);
|
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
|
||||||
|
var isFunction = function(value) {
|
||||||
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
|
return typeof value === 'function';
|
||||||
for (var idx = 0; idx < errorProps.length; idx++) {
|
};
|
||||||
this[errorProps[idx]] = tmp[errorProps[idx]];
|
// fallback for older versions of Chrome and Safari
|
||||||
}
|
if (isFunction(/x/)) {
|
||||||
};
|
isFunction = function(value) {
|
||||||
Handlebars.Exception.prototype = new Error();
|
return typeof value === 'function' && toString.call(value) === '[object Function]';
|
||||||
|
};
|
||||||
// Build out our basic SafeString type
|
}
|
||||||
Handlebars.SafeString = function(string) {
|
var isFunction;
|
||||||
this.string = string;
|
__exports__.isFunction = isFunction;
|
||||||
};
|
var isArray = Array.isArray || function(value) {
|
||||||
Handlebars.SafeString.prototype.toString = function() {
|
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
||||||
return this.string.toString();
|
};
|
||||||
};
|
__exports__.isArray = isArray;
|
||||||
|
|
||||||
var escape = {
|
function escapeExpression(string) {
|
||||||
"&": "&",
|
// don't escape SafeStrings, since they're already safe
|
||||||
"<": "<",
|
if (string instanceof SafeString) {
|
||||||
">": ">",
|
return string.toString();
|
||||||
'"': """,
|
} else if (!string && string !== 0) {
|
||||||
"'": "'",
|
return "";
|
||||||
"`": "`"
|
}
|
||||||
};
|
|
||||||
|
// Force a string conversion as this will be done by the append regardless and
|
||||||
var badChars = /[&<>"'`]/g;
|
// the regex test will do this transparently behind the scenes, causing issues if
|
||||||
var possible = /[&<>"'`]/;
|
// an object's to string has escaped characters in it.
|
||||||
|
string = "" + string;
|
||||||
var escapeChar = function(chr) {
|
|
||||||
return escape[chr] || "&";
|
if(!possible.test(string)) { return string; }
|
||||||
};
|
return string.replace(badChars, escapeChar);
|
||||||
|
}
|
||||||
Handlebars.Utils = {
|
|
||||||
extend: function(obj, value) {
|
__exports__.escapeExpression = escapeExpression;function isEmpty(value) {
|
||||||
for(var key in value) {
|
if (!value && value !== 0) {
|
||||||
if(value.hasOwnProperty(key)) {
|
return true;
|
||||||
obj[key] = value[key];
|
} else if (isArray(value) && value.length === 0) {
|
||||||
}
|
return true;
|
||||||
}
|
} else {
|
||||||
},
|
return false;
|
||||||
|
}
|
||||||
escapeExpression: function(string) {
|
}
|
||||||
// don't escape SafeStrings, since they're already safe
|
|
||||||
if (string instanceof Handlebars.SafeString) {
|
__exports__.isEmpty = isEmpty;
|
||||||
return string.toString();
|
return __exports__;
|
||||||
} else if (string == null || string === false) {
|
})(__module3__);
|
||||||
return "";
|
|
||||||
}
|
// handlebars/exception.js
|
||||||
|
var __module4__ = (function() {
|
||||||
// Force a string conversion as this will be done by the append regardless and
|
"use strict";
|
||||||
// the regex test will do this transparently behind the scenes, causing issues if
|
var __exports__;
|
||||||
// an object's to string has escaped characters in it.
|
|
||||||
string = string.toString();
|
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
|
||||||
|
|
||||||
if(!possible.test(string)) { return string; }
|
function Exception(message, node) {
|
||||||
return string.replace(badChars, escapeChar);
|
var line;
|
||||||
},
|
if (node && node.firstLine) {
|
||||||
|
line = node.firstLine;
|
||||||
isEmpty: function(value) {
|
|
||||||
if (!value && value !== 0) {
|
message += ' - ' + line + ':' + node.firstColumn;
|
||||||
return true;
|
}
|
||||||
} else if(toString.call(value) === "[object Array]" && value.length === 0) {
|
|
||||||
return true;
|
var tmp = Error.prototype.constructor.call(this, message);
|
||||||
} else {
|
|
||||||
return false;
|
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
|
||||||
}
|
for (var idx = 0; idx < errorProps.length; idx++) {
|
||||||
}
|
this[errorProps[idx]] = tmp[errorProps[idx]];
|
||||||
};
|
}
|
||||||
;
|
|
||||||
// lib/handlebars/runtime.js
|
if (line) {
|
||||||
|
this.lineNumber = line;
|
||||||
Handlebars.VM = {
|
this.column = node.firstColumn;
|
||||||
template: function(templateSpec) {
|
}
|
||||||
// Just add water
|
}
|
||||||
var container = {
|
|
||||||
escapeExpression: Handlebars.Utils.escapeExpression,
|
Exception.prototype = new Error();
|
||||||
invokePartial: Handlebars.VM.invokePartial,
|
|
||||||
programs: [],
|
__exports__ = Exception;
|
||||||
program: function(i, fn, data) {
|
return __exports__;
|
||||||
var programWrapper = this.programs[i];
|
})();
|
||||||
if(data) {
|
|
||||||
programWrapper = Handlebars.VM.program(i, fn, data);
|
// handlebars/base.js
|
||||||
} else if (!programWrapper) {
|
var __module1__ = (function(__dependency1__, __dependency2__) {
|
||||||
programWrapper = this.programs[i] = Handlebars.VM.program(i, fn);
|
"use strict";
|
||||||
|
var __exports__ = {};
|
||||||
|
var Utils = __dependency1__;
|
||||||
|
var Exception = __dependency2__;
|
||||||
|
|
||||||
|
var VERSION = "1.3.0";
|
||||||
|
__exports__.VERSION = VERSION;var COMPILER_REVISION = 4;
|
||||||
|
__exports__.COMPILER_REVISION = COMPILER_REVISION;
|
||||||
|
var 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',
|
||||||
|
4: '>= 1.0.0'
|
||||||
|
};
|
||||||
|
__exports__.REVISION_CHANGES = REVISION_CHANGES;
|
||||||
|
var isArray = Utils.isArray,
|
||||||
|
isFunction = Utils.isFunction,
|
||||||
|
toString = Utils.toString,
|
||||||
|
objectType = '[object Object]';
|
||||||
|
|
||||||
|
function HandlebarsEnvironment(helpers, partials) {
|
||||||
|
this.helpers = helpers || {};
|
||||||
|
this.partials = partials || {};
|
||||||
|
|
||||||
|
registerDefaultHelpers(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
__exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = {
|
||||||
|
constructor: HandlebarsEnvironment,
|
||||||
|
|
||||||
|
logger: logger,
|
||||||
|
log: log,
|
||||||
|
|
||||||
|
registerHelper: function(name, fn, inverse) {
|
||||||
|
if (toString.call(name) === objectType) {
|
||||||
|
if (inverse || fn) { throw new Exception('Arg not supported with multiple helpers'); }
|
||||||
|
Utils.extend(this.helpers, name);
|
||||||
|
} else {
|
||||||
|
if (inverse) { fn.not = inverse; }
|
||||||
|
this.helpers[name] = fn;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
registerPartial: function(name, str) {
|
||||||
|
if (toString.call(name) === objectType) {
|
||||||
|
Utils.extend(this.partials, name);
|
||||||
|
} else {
|
||||||
|
this.partials[name] = str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function registerDefaultHelpers(instance) {
|
||||||
|
instance.registerHelper('helperMissing', function(arg) {
|
||||||
|
if(arguments.length === 2) {
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
throw new Exception("Missing helper: '" + arg + "'");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.registerHelper('blockHelperMissing', function(context, options) {
|
||||||
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
||||||
|
|
||||||
|
if (isFunction(context)) { context = context.call(this); }
|
||||||
|
|
||||||
|
if(context === true) {
|
||||||
|
return fn(this);
|
||||||
|
} else if(context === false || context == null) {
|
||||||
|
return inverse(this);
|
||||||
|
} else if (isArray(context)) {
|
||||||
|
if(context.length > 0) {
|
||||||
|
return instance.helpers.each(context, options);
|
||||||
|
} else {
|
||||||
|
return inverse(this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fn(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.registerHelper('each', function(context, options) {
|
||||||
|
var fn = options.fn, inverse = options.inverse;
|
||||||
|
var i = 0, ret = "", data;
|
||||||
|
|
||||||
|
if (isFunction(context)) { context = context.call(this); }
|
||||||
|
|
||||||
|
if (options.data) {
|
||||||
|
data = createFrame(options.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(context && typeof context === 'object') {
|
||||||
|
if (isArray(context)) {
|
||||||
|
for(var j = context.length; i<j; i++) {
|
||||||
|
if (data) {
|
||||||
|
data.index = i;
|
||||||
|
data.first = (i === 0);
|
||||||
|
data.last = (i === (context.length-1));
|
||||||
|
}
|
||||||
|
ret = ret + fn(context[i], { data: data });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(var key in context) {
|
||||||
|
if(context.hasOwnProperty(key)) {
|
||||||
|
if(data) {
|
||||||
|
data.key = key;
|
||||||
|
data.index = i;
|
||||||
|
data.first = (i === 0);
|
||||||
|
}
|
||||||
|
ret = ret + fn(context[key], {data: data});
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i === 0){
|
||||||
|
ret = inverse(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.registerHelper('if', function(conditional, options) {
|
||||||
|
if (isFunction(conditional)) { conditional = conditional.call(this); }
|
||||||
|
|
||||||
|
// Default behavior is to render the positive path if the value is truthy and not empty.
|
||||||
|
// The `includeZero` option may be set to treat the condtional as purely not empty based on the
|
||||||
|
// behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative.
|
||||||
|
if ((!options.hash.includeZero && !conditional) || Utils.isEmpty(conditional)) {
|
||||||
|
return options.inverse(this);
|
||||||
|
} else {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.registerHelper('unless', function(conditional, options) {
|
||||||
|
return instance.helpers['if'].call(this, conditional, {fn: options.inverse, inverse: options.fn, hash: options.hash});
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.registerHelper('with', function(context, options) {
|
||||||
|
if (isFunction(context)) { context = context.call(this); }
|
||||||
|
|
||||||
|
if (!Utils.isEmpty(context)) return options.fn(context);
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.registerHelper('log', function(context, options) {
|
||||||
|
var level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
|
||||||
|
instance.log(level, context);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var logger = {
|
||||||
|
methodMap: { 0: 'debug', 1: 'info', 2: 'warn', 3: 'error' },
|
||||||
|
|
||||||
|
// State enum
|
||||||
|
DEBUG: 0,
|
||||||
|
INFO: 1,
|
||||||
|
WARN: 2,
|
||||||
|
ERROR: 3,
|
||||||
|
level: 3,
|
||||||
|
|
||||||
|
// can be overridden in the host environment
|
||||||
|
log: function(level, obj) {
|
||||||
|
if (logger.level <= level) {
|
||||||
|
var method = logger.methodMap[level];
|
||||||
|
if (typeof console !== 'undefined' && console[method]) {
|
||||||
|
console[method].call(console, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
__exports__.logger = logger;
|
||||||
|
function log(level, obj) { logger.log(level, obj); }
|
||||||
|
|
||||||
|
__exports__.log = log;var createFrame = function(object) {
|
||||||
|
var obj = {};
|
||||||
|
Utils.extend(obj, object);
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
__exports__.createFrame = createFrame;
|
||||||
|
return __exports__;
|
||||||
|
})(__module2__, __module4__);
|
||||||
|
|
||||||
|
// handlebars/runtime.js
|
||||||
|
var __module5__ = (function(__dependency1__, __dependency2__, __dependency3__) {
|
||||||
|
"use strict";
|
||||||
|
var __exports__ = {};
|
||||||
|
var Utils = __dependency1__;
|
||||||
|
var Exception = __dependency2__;
|
||||||
|
var COMPILER_REVISION = __dependency3__.COMPILER_REVISION;
|
||||||
|
var REVISION_CHANGES = __dependency3__.REVISION_CHANGES;
|
||||||
|
|
||||||
|
function checkRevision(compilerInfo) {
|
||||||
|
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
|
||||||
|
currentRevision = COMPILER_REVISION;
|
||||||
|
|
||||||
|
if (compilerRevision !== currentRevision) {
|
||||||
|
if (compilerRevision < currentRevision) {
|
||||||
|
var runtimeVersions = REVISION_CHANGES[currentRevision],
|
||||||
|
compilerVersions = REVISION_CHANGES[compilerRevision];
|
||||||
|
throw new Exception("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 new Exception("Template was precompiled with a newer version of Handlebars than the current runtime. "+
|
||||||
|
"Please update your runtime to a newer version ("+compilerInfo[1]+").");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__exports__.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial
|
||||||
|
|
||||||
|
function template(templateSpec, env) {
|
||||||
|
if (!env) {
|
||||||
|
throw new Exception("No environment passed to template");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: Using env.VM references rather than local var references throughout this section to allow
|
||||||
|
// for external users to override these as psuedo-supported APIs.
|
||||||
|
var invokePartialWrapper = function(partial, name, context, helpers, partials, data) {
|
||||||
|
var result = env.VM.invokePartial.apply(this, arguments);
|
||||||
|
if (result != null) { return result; }
|
||||||
|
|
||||||
|
if (env.compile) {
|
||||||
|
var options = { helpers: helpers, partials: partials, data: data };
|
||||||
|
partials[name] = env.compile(partial, { data: data !== undefined }, env);
|
||||||
|
return partials[name](context, options);
|
||||||
|
} else {
|
||||||
|
throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Just add water
|
||||||
|
var container = {
|
||||||
|
escapeExpression: Utils.escapeExpression,
|
||||||
|
invokePartial: invokePartialWrapper,
|
||||||
|
programs: [],
|
||||||
|
program: function(i, fn, data) {
|
||||||
|
var programWrapper = this.programs[i];
|
||||||
|
if(data) {
|
||||||
|
programWrapper = program(i, fn, data);
|
||||||
|
} else if (!programWrapper) {
|
||||||
|
programWrapper = this.programs[i] = program(i, fn);
|
||||||
|
}
|
||||||
|
return programWrapper;
|
||||||
|
},
|
||||||
|
merge: function(param, common) {
|
||||||
|
var ret = param || common;
|
||||||
|
|
||||||
|
if (param && common && (param !== common)) {
|
||||||
|
ret = {};
|
||||||
|
Utils.extend(ret, common);
|
||||||
|
Utils.extend(ret, param);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
programWithDepth: env.VM.programWithDepth,
|
||||||
|
noop: env.VM.noop,
|
||||||
|
compilerInfo: null
|
||||||
|
};
|
||||||
|
|
||||||
|
return function(context, options) {
|
||||||
|
options = options || {};
|
||||||
|
var namespace = options.partial ? options : env,
|
||||||
|
helpers,
|
||||||
|
partials;
|
||||||
|
|
||||||
|
if (!options.partial) {
|
||||||
|
helpers = options.helpers;
|
||||||
|
partials = options.partials;
|
||||||
|
}
|
||||||
|
var result = templateSpec.call(
|
||||||
|
container,
|
||||||
|
namespace, context,
|
||||||
|
helpers,
|
||||||
|
partials,
|
||||||
|
options.data);
|
||||||
|
|
||||||
|
if (!options.partial) {
|
||||||
|
env.VM.checkRevision(container.compilerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return programWrapper;
|
|
||||||
},
|
__exports__.template = template;function programWithDepth(i, fn, data /*, $depth */) {
|
||||||
merge: function(param, common) {
|
var args = Array.prototype.slice.call(arguments, 3);
|
||||||
var ret = param || common;
|
|
||||||
|
var prog = function(context, options) {
|
||||||
if (param && common) {
|
options = options || {};
|
||||||
ret = {};
|
|
||||||
Handlebars.Utils.extend(ret, common);
|
return fn.apply(this, [context, options.data || data].concat(args));
|
||||||
Handlebars.Utils.extend(ret, param);
|
};
|
||||||
|
prog.program = i;
|
||||||
|
prog.depth = args.length;
|
||||||
|
return prog;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
},
|
__exports__.programWithDepth = programWithDepth;function program(i, fn, data) {
|
||||||
programWithDepth: Handlebars.VM.programWithDepth,
|
var prog = function(context, options) {
|
||||||
noop: Handlebars.VM.noop,
|
options = options || {};
|
||||||
compilerInfo: null
|
|
||||||
};
|
return fn(context, options.data || data);
|
||||||
|
};
|
||||||
return function(context, options) {
|
prog.program = i;
|
||||||
options = options || {};
|
prog.depth = 0;
|
||||||
var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
|
return prog;
|
||||||
|
}
|
||||||
var compilerInfo = container.compilerInfo || [],
|
|
||||||
compilerRevision = compilerInfo[0] || 1,
|
__exports__.program = program;function invokePartial(partial, name, context, helpers, partials, data) {
|
||||||
currentRevision = Handlebars.COMPILER_REVISION;
|
var options = { partial: true, helpers: helpers, partials: partials, data: data };
|
||||||
|
|
||||||
if (compilerRevision !== currentRevision) {
|
if(partial === undefined) {
|
||||||
if (compilerRevision < currentRevision) {
|
throw new Exception("The partial " + name + " could not be found");
|
||||||
var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision],
|
} else if(partial instanceof Function) {
|
||||||
compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision];
|
return partial(context, options);
|
||||||
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]+").";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
__exports__.invokePartial = invokePartial;function noop() { return ""; }
|
||||||
return result;
|
|
||||||
};
|
__exports__.noop = noop;
|
||||||
},
|
return __exports__;
|
||||||
|
})(__module2__, __module4__, __module1__);
|
||||||
programWithDepth: function(i, fn, data /*, $depth */) {
|
|
||||||
var args = Array.prototype.slice.call(arguments, 3);
|
// handlebars.runtime.js
|
||||||
|
var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
|
||||||
var program = function(context, options) {
|
"use strict";
|
||||||
options = options || {};
|
var __exports__;
|
||||||
|
/*globals Handlebars: true */
|
||||||
return fn.apply(this, [context, options.data || data].concat(args));
|
var base = __dependency1__;
|
||||||
};
|
|
||||||
program.program = i;
|
// Each of these augment the Handlebars object. No need to setup here.
|
||||||
program.depth = args.length;
|
// (This is done to easily share code between commonjs and browse envs)
|
||||||
return program;
|
var SafeString = __dependency2__;
|
||||||
},
|
var Exception = __dependency3__;
|
||||||
program: function(i, fn, data) {
|
var Utils = __dependency4__;
|
||||||
var program = function(context, options) {
|
var runtime = __dependency5__;
|
||||||
options = options || {};
|
|
||||||
|
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
|
||||||
return fn(context, options.data || data);
|
var create = function() {
|
||||||
};
|
var hb = new base.HandlebarsEnvironment();
|
||||||
program.program = i;
|
|
||||||
program.depth = 0;
|
Utils.extend(hb, base);
|
||||||
return program;
|
hb.SafeString = SafeString;
|
||||||
},
|
hb.Exception = Exception;
|
||||||
noop: function() { return ""; },
|
hb.Utils = Utils;
|
||||||
invokePartial: function(partial, name, context, helpers, partials, data) {
|
|
||||||
var options = { helpers: helpers, partials: partials, data: data };
|
hb.VM = runtime;
|
||||||
|
hb.template = function(spec) {
|
||||||
if(partial === undefined) {
|
return runtime.template(spec, hb);
|
||||||
throw new Handlebars.Exception("The partial " + name + " could not be found");
|
};
|
||||||
} else if(partial instanceof Function) {
|
|
||||||
return partial(context, options);
|
return hb;
|
||||||
} else if (!Handlebars.compile) {
|
};
|
||||||
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
|
||||||
} else {
|
var Handlebars = create();
|
||||||
partials[name] = Handlebars.compile(partial, {data: data !== undefined});
|
Handlebars.create = create;
|
||||||
return partials[name](context, options);
|
|
||||||
}
|
__exports__ = Handlebars;
|
||||||
}
|
return __exports__;
|
||||||
};
|
})(__module1__, __module3__, __module4__, __module2__, __module5__);
|
||||||
|
|
||||||
Handlebars.template = Handlebars.VM.template;
|
return __module0__;
|
||||||
;
|
})();
|
||||||
// lib/handlebars/browser-suffix.js
|
|
||||||
if (typeof module === 'object' && module.exports) {
|
|
||||||
// CommonJS
|
|
||||||
module.exports = Handlebars;
|
|
||||||
|
|
||||||
} else if (typeof define === "function" && define.amd) {
|
|
||||||
// AMD modules
|
|
||||||
define(function() { return Handlebars; });
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// other, i.e. browser
|
|
||||||
this.Handlebars = Handlebars;
|
|
||||||
}
|
|
||||||
}).call(this);
|
|
||||||
;
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,6 @@
|
|||||||
|
define([], function () {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
return window.Handlebars;
|
||||||
|
});
|
Loading…
Reference in new issue