Sha256: 22812c030876cf5a6af7bdd5850b2a5623be8f5a69085623445fe1378dc57459
Contents?: true
Size: 1.56 KB
Versions: 8
Compression:
Stored size: 1.56 KB
Contents
module ExpressTemplates module Components module Capabilities # For compononets that only display themselves # conditionally module Suppressable def self.included(base) base.class_eval do class_attribute :suppression_condition_name self.suppression_condition_name = nil class_attribute :reverse_suppression_condition self.reverse_suppression_condition = false def self.emits_unless(name) self.suppression_condition_name = name self.reverse_suppression_condition = true include OverrideMethods end def self.emits_if(name) self.suppression_condition_name = name include OverrideMethods end end end end module OverrideMethods def start_tag if reverse_suppression_condition super unless self.send(suppression_condition_name) else super if self.send(suppression_condition_name) end end def end_tag if reverse_suppression_condition super unless self.send(suppression_condition_name) else super if self.send(suppression_condition_name) end end def build(*args) if reverse_suppression_condition super(*args) unless self.send(suppression_condition_name) else super(*args) if self.send(suppression_condition_name) end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems