summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Branca <chewbranca@gmail.com>2013-03-15 11:53:35 -0700
committerRussell Branca <chewbranca@gmail.com>2013-03-15 14:37:35 -0700
commit017167c6b6d9b62bdfd47a2402af173e5e3246c6 (patch)
tree8044ace8990ddbad4367e403bcf98ef8d4d5bb31
parentd845edd531db035d1c80efd30e99a38ac88f803a (diff)
downloadcouchdb-fauxton-rebase.tar.gz
Add a helper system for templatesfauxton-rebase
-rw-r--r--src/fauxton/app/app.js9
-rw-r--r--src/fauxton/app/helpers.js35
2 files changed, 43 insertions, 1 deletions
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index 4c4d92cae..0d9672064 100644
--- a/src/fauxton/app/app.js
+++ b/src/fauxton/app/app.js
@@ -4,11 +4,13 @@ define([
"lodash",
"backbone",
+ "helpers",
+
// Plugins.
"plugins/backbone.layoutmanager"
],
-function($, _, Backbone) {
+function($, _, Backbone, Helpers) {
// Provide a global location to place configuration settings and module
// creation.
@@ -27,6 +29,11 @@ function($, _, Backbone) {
prefix: "app/",
+ // Inject app/helper.js for shared functionality across all html templates
+ render: function(template, context) {
+ return template(_.extend(Helpers, context));
+ },
+
fetch: function(path) {
// Initialize done for use in async-mode
var done;
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
new file mode 100644
index 000000000..6b3a7cd5e
--- /dev/null
+++ b/src/fauxton/app/helpers.js
@@ -0,0 +1,35 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+
+// This file creates a set of helper functions that will be loaded for all html
+// templates. These functions should be self contained and not rely on any
+// external dependencies as they are loaded prior to the application. We may
+// want to change this later, but for now this should be thought of as a
+// "purely functional" helper system.
+
+
+define([
+],
+
+function() {
+
+ var Helpers = {};
+
+ Helpers.imageUrl = function(path) {
+ // TODO: add dynamic path for different deploy targets
+ return path;
+ };
+
+ return Helpers;
+});
+