Added support for inline nested templates

Double check that this doesn't have negative effects on dependent projects before merging. If it does, move the relevant parts here as failing tests.