Dynamically Specifying a View Template

Learn how to dynamically provide templates to views in Marionette.

We'll cover the following

In the code that we've modified so far, we’ve specified the template as a permanent attribute on our view because we’re always going to use the same template in this case. However, it’s also possible to dynamically provide templates to views. Let’s see how that’s done.

Changing the template

We already have our app working to display a static view that is hard-coded within our view definition. Let’s override it at runtime with a different template.

First, we need to define a new template to use, which we’ll include right below our existing template:

Get hands-on with 1200+ tech skills courses.