Sha256: be804e7f3690742328bf68d8a09836333d5ef47973a6d7c372442b721c34e3df
Contents?: true
Size: 1018 Bytes
Versions: 6
Compression:
Stored size: 1018 Bytes
Contents
require 'active_admin/arbre/html/element' module Arbre class Context < Arbre::HTML::Element def indent_level # A context does not increment the indent_level super - 1 end def bytesize cached_html.bytesize end alias :length :bytesize def respond_to?(method) super || cached_html.respond_to?(method) end # Webservers treat Arbre::Context as a string. We override # method_missing to delegate to the string representation # of the html. def method_missing(method, *args, &block) if cached_html.respond_to? method cached_html.send method, *args, &block else super end end private # Caches the rendered HTML so that we don't re-render just to # get the content lenght or to delegate a method to the HTML def cached_html if defined?(@cached_html) @cached_html else html = to_s @cached_html = html if html.length > 0 html end end end end
Version data entries
6 entries across 6 versions & 2 rubygems