Move YAML logic from template to plugin.