Polymer-templated synthesis of nanoparticles