How does NCM write to different devices' NVRAM using their appropriate commands

I can see when I run a Config Change Template for one of the built-in Juniper templates, it does a commit and-quit when I choose the write to NVRAM option. Similarly, when I run a built-in Cisco template it does a write mem. How does the system know what options to use for which vendor? I have a HP Procurve switch and when I choose the NVRAM option it fails to write and I see in the error log a strange {$Config} option even though a write mem works fine for it when I manually input it in the script. I would prefer to not hard code it in the script in case I want to test a script out before committing it.