Explorar o código

Improve EntryPage#subViewClass

Thibaut Courouble %!s(int64=9) %!d(string=hai) anos
pai
achega
ed2806499e

+ 6 - 0
assets/javascripts/lib/util.coffee

@@ -272,6 +272,12 @@ $.escapeRegexp = (string) ->
 $.urlDecode = (string) ->
   decodeURIComponent string.replace(/\+/g, '%20')
 
+$.classify = (string) ->
+  string = string.split('_')
+  for substr, i in string
+    string[i] = substr[0].toUpperCase() + substr[1..]
+  string.join('')
+
 #
 # Miscellaneous
 #

+ 1 - 2
assets/javascripts/views/content/entry_page.coffee

@@ -71,8 +71,7 @@ class app.views.EntryPage extends app.View
     return
 
   subViewClass: ->
-    docType = @entry.doc.type
-    app.views["#{docType[0].toUpperCase()}#{docType[1..]}Page"] or app.views.BasePage
+    app.views["#{$.classify(@entry.doc.type)}Page"] or app.views.BasePage
 
   getTitle: ->
     @entry.doc.fullName + if @entry.isIndex() then ' documentation' else " / #{@entry.name}"