Fix for parsing inverse queries in template

Change-Id: Id33aab754d4a14986da54ca4ceceb18625680f46