]> git.cworth.org Git - obsolete/notmuch-web/blobdiff - node_modules/express/lib/view/partial.js
Install the "express" node module via npm
[obsolete/notmuch-web] / node_modules / express / lib / view / partial.js
diff --git a/node_modules/express/lib/view/partial.js b/node_modules/express/lib/view/partial.js
new file mode 100644 (file)
index 0000000..7d2f69b
--- /dev/null
@@ -0,0 +1,40 @@
+
+/*!
+ * Express - view - Partial
+ * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
+ * MIT Licensed
+ */
+
+/**
+ * Memory cache.
+ */
+
+var cache = {};
+
+/**
+ * Resolve partial object name from the view path.
+ *
+ * Examples:
+ *
+ *   "user.ejs" becomes "user"
+ *   "forum thread.ejs" becomes "forumThread"
+ *   "forum/thread/post.ejs" becomes "post"
+ *   "blog-post.ejs" becomes "blogPost"
+ *
+ * @return {String}
+ * @api private
+ */
+
+exports.resolveObjectName = function(view){
+  return cache[view] || (cache[view] = view
+    .split('/')
+    .slice(-1)[0]
+    .split('.')[0]
+    .replace(/^_/, '')
+    .replace(/[^a-zA-Z0-9 ]+/g, ' ')
+    .split(/ +/).map(function(word, i){
+      return i
+        ? word[0].toUpperCase() + word.substr(1)
+        : word;
+    }).join(''));
+};
\ No newline at end of file