Comment 3 for bug 1258351

Revision history for this message
Clint Byrum (clint-fewbar) wrote : Re: Allow meta templates which can generate moustache-derived filenames

Robert, I actually did discuss this at length with Steve Baker, but I never fully expressed my intention here and had actually intended to do a bit more documentation of it before implementation was started.

The things that are missing:

* These are path-templates, and would be treated differently than regular templates. The first line would not be special in normal templates. Where to store them was something I hadn't decided on yet.
* The first line is a single pattern, not TARGETS=
* The referenced variables themselves must not have slashes. We won't allow substitution of hierarchy. The template author controls where you can write these still, but gives up the contents of the directory to the metadata.
* The whole template would need to be rendered with the block context from the path _and_ the rest of the metadata, which may be tricky unless pystache lets us pass in an active context.
* The use case for this is to be able to write things into a .d type directory structure. So given metadata like this:

apache:
  vhosts:
    - hostname: foo.com
      port: 80
      document_root: /srv/foo.com
    - hostname: bar.org
      port: 8000
      document_root: /srv/bar.org

Your path-controlled template would be

{{#apache.vhosts}}/etc/apache2/conf.d/{{hostname}}.conf{{/apache.vhosts}}
<VirtualHost *:{{port}}>
  DocumentRoot {{document_root}}
  ServerName {{hostname}}
</VirtualHost>

Steve Baker had another use case for it that made sense.