Method: Doing::Plugins.template_for_trigger
- Defined in:
- lib/doing/plugin_manager.rb
.template_for_trigger(trigger, type: :export, save_to: nil) ⇒ String
Find and return the appropriate template for a trigger string. Outputs a string that can be written out to the terminal for redirection
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/doing/plugin_manager.rb', line 242 def template_for_trigger(trigger, type: :export, save_to: nil) plugins[valid_type(type)].clone.delete_if { |_t, o| o[:templates].nil? }.each do |_, | [:templates].each do |t| next unless trigger =~ /^(?:#{t[:trigger].normalize_trigger})$/ tpl = [:class].template(trigger) return tpl unless save_to raise PluginException.new('No default filename defined', :export, t[:name]) unless t.key?(:filename) return save_template(tpl, save_to, t[:filename]) end end raise Errors::InvalidArgument, "No template type matched \"#{trigger}\"" end |