Replies: 1 comment 12 replies
-
The thing to consider is how much variation you want in the output vs how much is constant. For example, in your code above, maybe you want the delay time to be variable or perhaps step by 45 degrees rather than 90? Generally you want to use the Scriban template as the place to put the "constant" bits of the code as well as the logic to insert parameterised parts and then use the model to supply parameters. If you are intending that the user should be able to generate different kinds of things (perhaps you have an "accelerometer" module as well as a "servo" module) then one way to do it is to create a library so that you can write a template that looks something like
Having said, that Scriban is flexible enough that you can "reflect" over the model so it might be possible to model that defines the structure of the output as well as supplying parameters. For example, you could have a yaml model something like
then a template like this...
|
Beta Was this translation helpful? Give feedback.
-
I'm working on a project in which I'm trying to make a code generator for Arduino, I was trying Telosys and Acceleo, but these tools don't convince me completely. I would like to know if you consider that Textrude and scriban have enough capabilities to be able to make this code generator.
The idea that occurs to me is that for example a person places in the model section something like "servo" and by means of the template, a code like this is generated:
or something very similar.
Beta Was this translation helpful? Give feedback.
All reactions