Sha256: 37fa3aff40ef6efda9658132b713c076799614deb8da53c84bbf0341092af9df
Contents?: true
Size: 895 Bytes
Versions: 1
Compression:
Stored size: 895 Bytes
Contents
# frozen_string_literal: true # This mechanism is used by 3rd party plugins. # Normally you'd use partials from your own app module ComfortableMediaSurfer::ViewHooks # Array of declared hooks def self.hooks @hooks ||= {} end # Renders hook content def self.render(name, template, options = {}) out = '' (hooks[name.to_sym] || []).each do |path| out += template.render({ partial: path.first }.merge(options)) end out.html_safe end # Will declare a partial that will be rendered for this hook # Example: # ComfortableMediaSurfer::ViewHooks.add(:navigation, 'shared/navigation') def self.add(name, partial_path, position = 0) hooks[name.to_sym] ||= [] hooks[name.to_sym] << [partial_path, position] hooks[name.to_sym].sort_by!(&:last) end # Removing previously declared hook def self.remove(name) hooks.delete(name) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comfortable_media_surfer-3.0.0 | lib/comfortable_media_surfer/view_hooks.rb |