To make the pastry, place the flour into a large bowl. Cut the cold butter into small pieces and add them to the bowl. Gently rub the butter into the flour until pea-sized pieces remain.
Stir in the sugar. Add the milk and use your hands to bring together to form a soft, but not sticky, dough.
Gently knead the pastry a couple of times until it is smooth (don't over do this). Flatten the pastry into a disc and wrap in cling film. Place in the fridge for at least an hour.
Beat together the butter and the sugar until light and fluffy. I find it easiest to use a stand mixer but a bowl and a wooden spoon works well too.
Beat in the egg and vanilla along with a tablespoon of flour. Beat in the remaining flour until the mixture is smooth.
Blitz the pistachios in a food processor until they look like breadcrumbs. Stir into the butter and egg mixture. Chill in the fridge until ready to use.
Preheat oven to 190C/375F.
Cut the pastry into four pieces. Roll out on a floured surface until the pastry is a couple of millimetres thick. Spoon 3 tablespoons of frangipane into the centre of the pastry and gently spread out using the back of a spoon so that it's about 10 centimetres wide.
Cut the rhubarb into short lengths, not quite as wide as the frangipane. Toss in the maple syrup and lay on top of the frangipane. Trim the edges of the pastry so that you have a neatish border of a few centimetres around the frangipane. Fold the pastry in and press it down to seal the edges. Repeat for the rest of the pastry. Place on a lined baking sheet. Chill for at least 30 minutes if possible.
Brush the edges of the pastry with beaten egg. Sprinkle with demerara sugar and place in the oven. Bake for about 25 minutes until the edges of the pastry are golden brown and crisp and the frangipane is set. Serve warm with ice cream.