Regarding generating data inside the template, this custom extension was promising, but it was never released: