This repo contains a very basic templated component that demonstrates how simply this can be done.
It is not a complete working component for use in production, but the amount of flexibility and scope for extension in one page of code is pretty impressive to me.
Fork the project, run it and check out the samples.
Have a play - see if you can understand the way it uses RenderFragment templates.
Feel free to contribute samples/improvements.