Molecular templating of layered halide perovskite nanowires