I was wondering if in the future it would be possible to implement more reusable templating snippets that can be imported as needed on a screen-by-screen basis. A templating system something like importing JSON-esque stuff into, say, a web application or something.
The way things are now, Activity code is not very DRY: I’m constantly repeating the same snippets of code across many components in an Activity.
To illustrate a simple example I might use this sort of thing stays the same in every math input component I have in an Activity:
correct = this.numericValue=g.script.correct and this.submitted submitLabel: "Check My Answer" correct: correct suffix: when this.script.correct "✅" when this.submitted "🤔" otherwise ""
It’s abstracted enough that it really doesn’t matter what the question is about: same code. But I’m having to write that out or copy and paste it in every single time.
Better I think would be to import that entire swath of code into the component from globals container at the beginning of the Activity, like
response = globals.script and that’s that, overriding specifics where appropriate.
Too much abstraction? Useful? What do you think?