Sha256: 9b50ba20172641b36bbf9a4ede5722ddc9343164633210d569c1f19795b93021
Contents?: true
Size: 1.38 KB
Versions: 5
Compression:
Stored size: 1.38 KB
Contents
require "msgpack" class Card class View module Cache # A "stub" is a placeholder for a card view. # # Cached views use stubs so that _nesting_ content can remained cached # even while _nested_ content changes. The nested content's place is held # by a stub. # # A stub must contain all the information necessary to produce the view as intended. module Stub private # @return [String] def stub "(StUb#{stub_hash.to_json}sTuB)".html_safe # "(StUb#{bin_to_hex stub_hash.to_msgpack}sTuB)".html_safe end def bin_to_hex string string.unpack("H*").first end # @return [Hash] def stub_hash { cast: card.cast, view_opts: normalized_options.merge(normalized_visibility_options), format_opts: { nest_mode: format.nest_mode, override: root?, context_names: format.context_names } } # nest mode handling: # # Typically modes override views on nests, but stubs create non-standard nests. # Mode-based view overrides should NOT apply to standard render calls that have # been replaced with stubs - only to standard nest calls. The override value # is used to retain this distinction. end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems