New major release of foreman_templates - info for other plugin authors

Hi all,

I just merged foreman_templates PR #27 [1] into master. Most of this is
refactoring, but it does bring one new feature aimed at other plugins.

The new import code will first look for a metadata entry call "model". If
it finds this, it will attempt to call "import!" on whatever model is
specified there (after first calling constantize, of course). See [2] for
the exact code.

This means it's possible for any plugin to define a model with a method
called "import!" and handle what to do with the template passed to it by
foreman_templates, without adding code to foreman_templates itself. This
method does not have to inherit from core's Template type (although for
many things it will make sense to do so) - it needs only to accept the 3
args passed to it and return an appropriate Hash.

The README [3] contains the input/output expectations, and a trivialised
example of a plugin writing templates to disk.

This code is in master, as stated, and I expect to do a gem release soon
(waiting on one more PR). However, the "model" attribute will be ignored in
older versions of foreman_templates, so I may start sending PRs to
community_templates ahead of that release.

Enjoy!

[1] https://github.com/theforeman/foreman_templates/pull/27
[2] https://github.com/theforeman/foreman_templates/blob/master/
app/services/foreman_templates/template_importer.rb#L66
[3]
https://github.com/theforeman/foreman_templates#integration-with-other-foreman-plugins

ยทยทยท -- Greg IRC: gwmngilfen

Foreman_templates 3.0.0 went out today, which contains this option. You can
see an example implementation in my PR to Remote Execution [1].

I've done an early .0 release as we go into code-freeze for 1.13 so I can
iron out bugs. Testing / feedback is very welcome :wink:

[1] https://github.com/theforeman/foreman_remote_execution/pull/202

Cheers
Greg