generate code using Text::MicroTemplate (for flexibility)