Get name of prototype object
<p>I'm planning on writing a convention over configuration template source engine for KnockoutJS / MVC.
I'm started with a little client side POC and ran into a show stopper right away</p>

<p>My plan is use this syntax or something similar</p>

<pre><code>MyApp.EditCustomersViewModel = function() {
   ko.templates.loadView(this);
};
</code></pre>

<p>When doing this it will check the tamplate cache or fetch the templates from server using the object name as key.
The problem is I cant get the name of the prototype object, i tried this</p>

<pre><code>Object.prototype.getName = function() {
   var funcNameRegex = /function (.{1,})\(/;
   var results = (funcNameRegex).exec((this).constructor.toString());
   return (results &amp;&amp; results.length &gt; 1) ? results[1] : "";
};
</code></pre>

<p>If works for objects defined like this</p>

<pre><code>function MyClass() { 
}
</code></pre>

<p>If you add a prototype to the above object it will not work, or if you define it like this</p>

<pre><code>MyApp = {};
MyApp.MyClass = function() {
};
</code></pre>

<p>Prototype and scoping is two musts so this is a showstopper, any ideas?</p>

<p>Fiddle: <a href="http://jsfiddle.net/aRWLA/" rel="nofollow">http://jsfiddle.net/aRWLA/</a></p>

<p><strong>edit:</strong> The background for this is like this.</p>

<p>On the server you have structure like this </p>

<ul>
<li>Templates\ [ViewName]\index.html</li>
<li>Templates\ [ViewName]\sub-model-template.html</li>
</ul>

<p>on the client you will do </p>

<pre><code>MyApp.EditCustomersViewModel = function() {
   ko.templates.loadView(this);
};
</code></pre>

<p>which will generate a ajax request with the objects name as key, which will fetch all the templates for the view in question</p>
