History

Improve EntryPage#subViewClass

Thibaut Courouble committed 10 years ago

Commit ed280641 parent 0948b582 files · +7 −2Browse files

Unified · Split

2 files
  1. assets/javascripts/lib/util.coffee +6 −0
  2. assets/javascripts/views/content/entry_page.coffee +1 −2
assets/javascripts/lib/util.coffee+6−0
@@ -272,6 +272,12 @@ $.escapeRegexp = (string) -> · 271 unmodified lines
272272 $.urlDecode = (string) ->
273273 decodeURIComponent string.replace(/\+/g, '%20')
274274
275+$.classify = (string) ->
276+ string = string.split('_')
277+ for substr, i in string
278+ string[i] = substr[0].toUpperCase() + substr[1..]
279+ string.join('')
280+
275281 #
276282 # Miscellaneous
277283 #
assets/javascripts/views/content/entry_page.coffee+1−2
@@ -71,8 +71,7 @@ class app.views.EntryPage extends app.View · 70 unmodified lines
7171 return
7272
7373 subViewClass: ->
74− docType = @entry.doc.type
75− app.views["#{docType[0].toUpperCase()}#{docType[1..]}Page"] or app.views.BasePage
74+ app.views["#{$.classify(@entry.doc.type)}Page"] or app.views.BasePage
7675
7776 getTitle: ->
7877 @entry.doc.fullName + if @entry.isIndex() then ' documentation' else " / #{@entry.name}"