class Card::Format
Card::Format
and its subclasses ({Card::Format::HtmlFormat}, {Card::Format::JsonFormat}, {Card::Format::XmlFormat}, etc) are responsible for defining and rendering views.
However, monkeys (those who code in the Card/Decko framework) rarely write code directly in these classes. Instead they organize their code using {Cardio::Mod mods}.
{Cardio::Mod} explains how to set up a mod. {Card::Set::Format} explains how to use this and other format classes within a mod. {Card::Set::Format::AbstractFormat} introduces the view API, which is organized with these format classes.
Attributes
Public Class Methods
Source
# File lib/card/format.rb, line 48 def initialize card, opts={} @card = card require_card_to_initialize! opts.each { |key, value| instance_variable_set "@#{key}", value } include_set_format_modules end
Public Instance Methods
Source
# File lib/card/format.rb, line 77 def controller @controller || Env.controller ||= CardController.new end
Source
# File lib/card/format.rb, line 89 def escape_literal literal literal end
Source
# File lib/card/format.rb, line 61 def include_set_format_modules self.class.format_ancestry.reverse_each do |klass| card.set_format_modules(klass).each do |m| singleton_class.send :include, m end end end
Source
# File lib/card/format.rb, line 69 def page controller, view, slot_opts @controller = controller context_names # loads names and removes #name_context from slot_opts @card.run_callbacks :show_page do show view, slot_opts end end
Source
# File lib/card/format.rb, line 81 def request_url controller.request&.original_url || path end
Source
# File lib/card/format.rb, line 55 def require_card_to_initialize! return if @card raise Card::Error, ::I18n.t(:lib_exception_init_without_card) end