You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2013/03/15 22:50:08 UTC
[49/50] git commit: Add a helper system for templates
Add a helper system for templates
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/017167c6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/017167c6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/017167c6
Branch: refs/heads/fauxton-rebase
Commit: 017167c6b6d9b62bdfd47a2402af173e5e3246c6
Parents: d845edd
Author: Russell Branca <ch...@gmail.com>
Authored: Fri Mar 15 11:53:35 2013 -0700
Committer: Russell Branca <ch...@gmail.com>
Committed: Fri Mar 15 14:37:35 2013 -0700
----------------------------------------------------------------------
src/fauxton/app/app.js | 9 ++++++++-
src/fauxton/app/helpers.js | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/017167c6/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index 4c4d92c..0d96720 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;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/017167c6/src/fauxton/app/helpers.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
new file mode 100644
index 0000000..6b3a7cd
--- /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;
+});
+