parse advanced code to create and instantiate templates