Loop counters for included templates (fixes #16)