We're building a Django-based project with a template/generator component. This component will be separate from the project as such and can be Django/Python, Node, Java or whatever works. The idea is to generate questions based on a pattern. For eg., I would want to generate questions like "What is 2 + 3", "What is 5 + 8" based on the pattern "What is X + Y ; where X,Y < 10". In this sense, it's like a template engine.
The templates will contain references to objects with properties that are defined in the DB, say, a Bus. For eg, it could be something like
[object type="vehicle" weight="heavy"]
and it would have to pull a random object from the DB fulfilling the criteria : type="vehicle" weight="heavy" (bus/truck/jet) and then substitute that tag with an image, say, of a Bus. Also it would have to be able to handle some processing. Eg:
What is [X type="integer" lte="10"] + [Y type="integer" lte="10"]
[option X+Y correct_ans="true"]
[option X-Y correct_ans="false"]
[option X+y+1 correct_ans="false"]
The engine would be expected to fill in a random integer value <= 10 for X and Y and show radioboxes for each of the options. Would also have to store the fact that the first option is the correct answer.
Does it to make sense to write something from the scratch? Or is it better to use an existing templating system (like Django's own templating system) as a starting point? Any suggestions on how I can approach this?
edit : Clarification of use case