Skip to content
Myr

partial.js

This file

Path

lib/view/partial.js

40 lines · 774 bytes · JavaScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than fb38d9c point at it.

add test for res.send(undefined)Aaron Heckmannbefore adoptionfb38d9c

lines 1–40why, one step back
1
2/*!3 * Express - view - Partial4 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>5 * MIT Licensed6 */78/**9 * Memory cache.10 */1112var cache = {};1314/**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 private26 */2728exports.resolveObjectName = function(view){29 return cache[view] || (cache[view] = view30 .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 i37 ? word[0].toUpperCase() + word.substr(1)38 : word;39 }).join(''));40};