In my backbone app I have a view that needs to be rendered using different templates, dependant on a variable that is passed to the view. I am using require js and want to know if there is smart way of doing this.
Here is how I would call instantiate the new view:
var templateType = 'Template1'
var view = new DetailView({model:thisModel, 'templateType': templateType}); 
Here is an example of the view:
define(['backbone', 
    'text!templates/template1.html',
    'text!templates/template2.html' ], 
    function(Backbone, 
            Template1,
            Template2){
var DetailView = Backbone.View.extend({
    tagName : 'li',
    className: 'detail-tag',        
    initialize : function(){    
        this.detailTemplate = _.template( this.options.templateType );
        this.render();          
    },
This does not give me the required result. How do I use the options value to link to the require variable - Template1? I realise I could probably set up a switch statement or something, but that seems a bit messy. Is there a neater way of doing it?
Thanks
 
    