For those that read a lot of my posts, going to sound like a broken record, but this looks like a job for the "Compliance" portion of NCM, not the Config Change Template portion.
By using the "Config Block" portion of Compliance manager, you should be able to do what you want, then you can write a remediation rule to execute the changes based on the config blocks that meet your criteria.
Let's say you wanted to set all access ports (ie: not trunks) to have "spanning-tree portfast" set.
Create a compliance rule, set it to "Advanced Config Search" and to search in "Config Block". Alert on rule if "String is found" and then set it to "must not contain" "Regular Expression" and I would use "^\s*switchport mode trunk" as the "String". I would also add another rule based on what you want set, in this case "spanning-tree portfast", so it doesn't re-set the same option over again if not needed. So that would be another "must not contain" "Regular Expression" and in the "String" put "^\s*spanning-tree portfast". Here is a screenshot.
Image may be NSFW.
Clik here to view.
Then, set up the "Search Config File/Block" as such, the block start should be something like "^interface (Fast|Gigabit)Ethernet.*" (so as not to match VLAN interfaces, customize this as needed). The "Config Block End" would be "^!" or a line with just an exclamation point on it, which is the case at the end of each interface config. Like this:
Image may be NSFW.
Clik here to view.
Then you just set up your remediation. Tell it to "Run script on each config block in violation" and "Execute Script in Config Mode" and I'd recommend also "Save to NVRAM". Your script will be one line with "${ConfigBlockStartLine}" and the next with your change, in this case "spanning-tree portfast". Note the "TEST" button below, be sure to test this before using it!!! Make sure its going to do what you want.
Like this:
Image may be NSFW.
Clik here to view.
I think this will do exactly what you want with whatever tweaks you might need to do...