Preheat the oven to 200°C/400ºF/Gas Mark 6. Heat the oil and butter in a frying pan, add the onion and fry for 5 minutes, stirring until softened. Add the sugar and fry for 5 minutes, stirring more frequently until lightly browned.
Mix in the blackberries and thyme then season with salt and pepper.
Unroll the pastry then cut 4 heart shapes, transfer to a wetted baking sheet and prick the centre of each heart with a fork, leaving a border about 2cm all the way round.
Brush the pastry with beaten egg then pile the onion and blackberry mix in the centre of each pastry heart. Bake for 10 minutes until the pastry is well risen and lightly browned.
Top each with a slice of goats cheese, a few extra thyme leaves and some salt and pepper. Bake for 4-5 minutes more until the cheese has just softened and the pastry is cooked.
Meanwhile, whisk the vinegar, oil, sugar and mustard together in a bowl to make a dressing. Add a little salt and pepper then the salad leaves and raspberries and gently toss together.
Arrange one heart per serving for a starter, two for a main course on to plates with a little salad.