Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use separate custom templates for each model

  • Loading branch information...
commit 3e74b11f55f907c406f52e098542afc1c6fc5043 1 parent dd569ea
Roman authored
4 app/assets/javascripts/character/base/application.coffee
View
@@ -32,12 +32,12 @@ class @Character extends Backbone.Marionette.Application
# skip settings module
if m.moduleName != 'Settings'
@add_menu_item(m.options.pluralized_name, m.options.scope, m.options.icon)
-
+
@layout.select_menu_item(@layout.scope)
jump_to_first_app: ->
- if window.location.hash == ""
+ if window.location.hash == ""
path = $('#menu .top-bar-section .left li a:eq(0)').attr 'href'
window.location.hash = path
11 app/assets/javascripts/character/generic/views/collection.coffee
View
@@ -1,5 +1,9 @@
class @GenericCollectionItemView extends Backbone.Marionette.ItemView
- template: JST["character/generic/templates/custom/collection_item"] || JST["character/generic/templates/collection_item"]
+ template: (serialized_model) =>
+ custom_template = JST["character/generic/templates/#{ window.character_namespace }/#{ @model.collection.options.scope }/collection_item"]
+ regular_template = JST["character/generic/templates/collection_item"]
+ (custom_template || regular_template)(serialized_model)
+
tagName: 'li'
modelEvents:
'change': 'render'
@@ -11,7 +15,10 @@ class @GenericCollectionItemView extends Backbone.Marionette.ItemView
class @GenericCollectionEmptyView extends Backbone.Marionette.ItemView
- template: JST["character/generic/templates/custom/collection_empty"] || JST["character/generic/templates/collection_empty"]
+ template: (serialized_model) ->
+ custom_template = JST["character/generic/templates/#{ window.character_namespace }/collection_empty"]
+ regular_template = JST["character/generic/templates/collection_empty"]
+ (custom_template || regular_template)(serialized_model)
class @GenericCollectionView extends Backbone.Marionette.CollectionView
5 app/assets/javascripts/character/generic/views/details.coffee
View
@@ -1,5 +1,8 @@
class @GenericDetailsView extends Backbone.Marionette.Layout
- template: JST["character/generic/templates/custom/details"] || JST["character/generic/templates/details"]
+ template: (serialized_model) =>
+ custom_template = JST["character/generic/templates/#{ window.character_namespace }/#{ @collection.options.scope }/details"]
+ regular_template = JST["character/generic/templates/details"]
+ (custom_template || regular_template)(serialized_model)
regions:
header: '#details_header'
5 app/assets/javascripts/character/generic/views/details_header.coffee
View
@@ -1,5 +1,8 @@
class @GenericDetailsHeaderView extends Backbone.Marionette.ItemView
- template: JST["character/generic/templates/custom/details_header"] || JST["character/generic/templates/details_header"]
+ template: (serialized_model) =>
+ custom_template = JST["character/generic/templates/#{ window.character_namespace }/#{ @collection.options.scope }/details_header"]
+ regular_template = JST["character/generic/templates/details_header"]
+ (custom_template || regular_template)(serialized_model)
modelEvents:
'change': 'render'
5 app/assets/javascripts/character/generic/views/layout.coffee
View
@@ -1,5 +1,8 @@
class @GenericLayout extends Backbone.Marionette.Layout
- template: JST["character/generic/templates/custom/layout"] || JST["character/generic/templates/layout"]
+ template: (serialized_model) ->
+ custom_template = JST["character/generic/templates/#{ window.character_namespace }/layout"]
+ regular_template = JST["character/generic/templates/layout"]
+ (custom_template || regular_template)(serialized_model)
regions:
header: '#list_header'
Please sign in to comment.
Something went wrong with that request. Please try again.