Templating Design Sketch - XingFramework/xing-application-base GitHub Wiki

The next phase for XAB itself is to be converted into project templates rather than a base repo.

One possibility for this would be to set up yeoman - the features thereof would need to be examined, and it would mean having the basic tool being an npm, which I think we have some halfway reasonable chauvanism about. That said, yeoman already exists.

A Different Way

What I have in mind is like this: use Mustache templates for the project itself. Mustache is logic-less, in that only iterating over lists, and conditionals based on the presence of fields are allowed. The nice thing about this is that we can extract all the context references from the templates.

Based on that dictionary of required values extracted from the templates, we can compose essentially a form for the user to fill out (I'm picturing a YAML-to-$EDITOR at first). Given that the list will probably get large, we'll build an "assistant" to fill in as much as possible automatically. In the end, we can probably list fields on the command line, have the assistant fill out the whole template context, present that for review (optionally) and then run templating.

The vision I have is of a clean, tight development cycle of templates, where the templating tool itself can guide next steps. i.e.:

Workflow

  • Copy a file and mark it up as a Mustache template.
  • Run a test templating command.
  • The tool issues a warning that no assistant claims your template file.
  • The tool demands a value for all the fields you just added.
  • You tell the tool to create an assistant file at an appropriate path.
  • The tool templates an assistant for your template, so that it's clear how build a basic assistant.
  • Commit your code, distribute as a gem.