Example #1
0
		}).always(function(result) {
			try {
				var data = result.responseText || "";
				if (result.status === 200) {
					// We add the script tag here to have Syntax highlighting in .tmpl file
					var e = $(_config.htmlHolder);
					if (data.indexOf("<script") === -1) {
						e.append($('<script id="' + domId + '" type="text/x-handlebars-template">' + data + "</script>"));
					} else {
						$(data).each(function(i, script) {
							e.append(script);
						});
					}
					deferred.resolve($("#" + domId).html());
				} else {
					if (options.failNotFound) throw new Error("Template not found status[" + result.status + "]");
					deferred.resolve(null);
				}
			} catch (e) {
				deferred.reject(utils.toDiagnose({
					exception: e,
					where: "stemplates._get [" + filePath + "]"
				}));
			}
		});
Example #2
0
var _resolveError = function(deferred, name, e) {
	var content = '<div class="alert alert-danger" role="alert"> Error loading template ' + name + '</div>';
	if (utils.isError(e)) {
		content += "<p>Error</p><pre>" + JSON.stringify(utils.toDiagnose(e, null, true), null, 2) + "<pre>";
	}
	deferred.resolve({
		content: content,
		header: ""
	});
};