class Babl::ActionView::TemplateHandler

Public Class Methods

cached_templates() click to toggle source
# File lib/babl/railtie.rb, line 9
def cached_templates
    @cached_templates ||= {}
end
call(template) click to toggle source
# File lib/babl/railtie.rb, line 13
def call(template)
    Babl.config.cache_templates ? cached_call(template) : uncached_call(template)
end

Private Class Methods

cached_call(template) click to toggle source
# File lib/babl/railtie.rb, line 19
                def cached_call(template)
                    cached_templates[template.identifier] ||= Babl.compile {
                        pin { |root|
                            nav(:context).named_pin(:rails_context).call(root.nav(:locals))
                                .source(template.source, template.identifier)
                        }
                    }

                    <<-RUBY
                        compiled = ::Babl::ActionView::TemplateHandler.cached_templates[#{template.identifier.inspect}]
                        compiled.json(locals: local_assigns, context: self)
                    RUBY
                end
uncached_call(template) click to toggle source
# File lib/babl/railtie.rb, line 33
                def uncached_call(template)
                    <<-RUBY
                        Babl.compile {
                            pin do |root|
                                nav(:context).named_pin(:rails_context).call(root.nav(:locals)).source(
                                #{template.source.inspect},
                                #{template.identifier.inspect}
                                )
                            end
                        }.json(locals: local_assigns, context: self)
                    RUBY
                end