I have a simple Django app that has a variety of views of various different asset types. I have various jQuery functions that key off the asset type name and so when I generate the page using the django template I use a template variable to fill in the asset type parameter in the javascript code...
$(document).ready(function()
{
$(".project").click(function() {return FiltersChanged('{{ asset_type }}', $('#filter_entry').val());});
});
I'm using this kind of paradigm a lot in the app and it seems a little awkward to me, I'm finding that i'm creating a lot of duplicate code in different template files simply because I need to fill in that {{asset_type}} variable and i'd like to be able to reduce the duplication and not need to generate that code in the template every time.
So, is there a better way to do this that doesn't require duplicating code in each page?