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 -- You received this message because you are subscribed to the Google Groups "foreman-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
