Skip to content

Commit

Permalink
Now rendering an error if an umknown box type is given.
Browse files Browse the repository at this point in the history
  • Loading branch information
lazee committed Feb 27, 2020
1 parent eec38f8 commit 34c8bd7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/premonition/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ def create_resource(b)
'title' => @resources.config['default']['title'],
'meta' => @resources.config['default']['meta']
}

if !@resources.config['types'].include? b['type']
c['title'] = ''
c['meta'] = { 'fa-icon' => 'fa-bug' }
c['template'] = '<div class="premonition error"><div class="fa {{meta.fa-icon}}"></div>'\
'<div class="content"><p class="header">PREMONITION ERROR: Invalid box type</p>You have specified an invalid box type "{{type}}". You can customize your own box types in `_config.yml`. See documentation for help.</div></div>'
return c
end

@resources.config['types'].each do |id, t|
next unless id == b['type']
c['title'] = b['title'].empty? || b['title'].nil? ? t['default_title'] : b['title']
Expand Down

0 comments on commit 34c8bd7

Please sign in to comment.