Should I use parameters in template scripting to control the output, or a separate specialized template?
- by asawyer
Would it be considered best practice to use a single template that changes it's output based on script values, or have multiple templates, and use the view to pick the correct one instead?
For example, in this underscope template:
<script type="text/template" id="SkillsetTemplate">
<div class='RegularMode <%= (skillset.get('InEditMode')===false)?'show':'hide' %>'>
</div>
<div class='EditMode <%= (skillset.get('InEditMode')===true)?'show':'hide' %>'>
</div>
</script>
I use a backbone model to bind against, and use the InEditMode attribute to pick which content to render.
Should I instead have a normal mode, and an edit mode template, and use the attribute on the model to pick the template ?
For background purposes, I am using backbone.js with underscore templates and an MVC3 backend.