This only quantizes the recording lenght but I think the loop will start to drift out of sync after time since it's length in samples won't neccessarily fit into the amount of clock ticks.
I think hardware loopers always apply a little bit of timestretching in order to keep the material in sync, since clock ticks might be inbetween samples.
But anyways @rbrt's looper are a great thing to start with.
The delay module of @DrJustice works great for doing this. You can feed it a clock input and use the divoverride inlet to set delay times that a subdivions of the clock pulse on the fly!
generally speaking the delay approach or the looper are good to start with. You can also start to patch your own looper, wich leaves you more flexibilty but wich is also more complex.