added dir as a global template variable