Sha256: 0d6fecfc769c0890d80e37cc759f6139a16eca5733d2c6f8ab3970fcdbe75fc8
Contents?: true
Size: 702 Bytes
Versions: 20
Compression:
Stored size: 702 Bytes
Contents
class Stasis class Helpers < Plugin controller_method :helpers before_render :before_render def initialize(stasis) @stasis = stasis @blocks = [] end # This event triggers before each file renders through Stasis. For each helper # `block`, evaluate the `block` in the scope of the `action` class. def before_render @blocks.each do |(path, block)| if _within?(path) @stasis.action.class.class_eval(&block) end end end # This method is bound to all controllers. Stores a block in the `@blocks` `Array`. def helpers(&block) if block @blocks << [ @stasis.path, block ] end end end end
Version data entries
20 entries across 20 versions & 1 rubygems