Module: BreezyTemplate::DefermentExtension
- Included in:
- BreezyTemplate
- Defined in:
- lib/breezy_template/deferment_extension.rb
Constant Summary collapse
- ACTIVE_MODES =
[:auto, :manual].freeze
Instance Method Summary collapse
- #_breezy_visit_current(path) ⇒ Object
- #_deferment_auto?(options) ⇒ Boolean
- #_deferment_options(options) ⇒ Object
- #_deferment_options?(options) ⇒ Boolean
- #_extended_options?(value) ⇒ Boolean
- #_mapping_element(element, options) ⇒ Object
- #_set_request_url_once(request_path) ⇒ Object
- #set!(key, value = BLANK, *args) ⇒ Object
Instance Method Details
#_breezy_visit_current(path) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/breezy_template/deferment_extension.rb', line 19 def _breezy_visit_current(path) uri = ::URI.parse(@request_path) qry = ::URI.decode_www_form(uri.query || '') << ["bzq", path.join('.')] uri.query = ::URI.encode_www_form(qry) "defers.push({url:'#{uri}'});" end |
#_deferment_auto?(options) ⇒ Boolean
34 35 36 |
# File 'lib/breezy_template/deferment_extension.rb', line 34 def _deferment_auto?() () == :auto end |
#_deferment_options(options) ⇒ Object
30 31 32 |
# File 'lib/breezy_template/deferment_extension.rb', line 30 def () [:defer] end |
#_deferment_options?(options) ⇒ Boolean
26 27 28 |
# File 'lib/breezy_template/deferment_extension.rb', line 26 def () && !![:defer] && (@search_path.nil? || @search_path.size == 0) end |
#_extended_options?(value) ⇒ Boolean
42 43 44 |
# File 'lib/breezy_template/deferment_extension.rb', line 42 def (value) (value) || super end |
#_mapping_element(element, options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/breezy_template/deferment_extension.rb', line 46 def _mapping_element(element, ) if () if ::Proc === () value = ().call(element) = .dup.merge({defer: value}) end end if () if _deferment_auto?() @js.push(_breezy_visit_current(@path)) end if .has_key? :key id_name = [:key] id_val = element[id_name] ::Hash[id_name, id_val] else ::BreezyTemplate::Var.new('undefined') end else super end end |
#_set_request_url_once(request_path) ⇒ Object
38 39 40 |
# File 'lib/breezy_template/deferment_extension.rb', line 38 def _set_request_url_once(request_path) @request_path ||= request_path end |
#set!(key, value = BLANK, *args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/breezy_template/deferment_extension.rb', line 7 def set!(key, value = BLANK, *args) = args[0] if ::Kernel.block_given? && () if _deferment_auto?() @js.push(_breezy_visit_current(@path)) end return _set_value key, ::BreezyTemplate::Var.new('undefined') else super end end |