]> git.cworth.org Git - obsolete/notmuch-web/blob - node_modules/express/lib/view/partial.js
Install the "express" node module via npm
[obsolete/notmuch-web] / node_modules / express / lib / view / partial.js
1
2 /*!
3  * Express - view - Partial
4  * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
5  * MIT Licensed
6  */
7
8 /**
9  * Memory cache.
10  */
11
12 var cache = {};
13
14 /**
15  * Resolve partial object name from the view path.
16  *
17  * Examples:
18  *
19  *   "user.ejs" becomes "user"
20  *   "forum thread.ejs" becomes "forumThread"
21  *   "forum/thread/post.ejs" becomes "post"
22  *   "blog-post.ejs" becomes "blogPost"
23  *
24  * @return {String}
25  * @api private
26  */
27
28 exports.resolveObjectName = function(view){
29   return cache[view] || (cache[view] = view
30     .split('/')
31     .slice(-1)[0]
32     .split('.')[0]
33     .replace(/^_/, '')
34     .replace(/[^a-zA-Z0-9 ]+/g, ' ')
35     .split(/ +/).map(function(word, i){
36       return i
37         ? word[0].toUpperCase() + word.substr(1)
38         : word;
39     }).join(''));
40 };