Module: TRMNL::Liquid

Defined in:
lib/trmnl/liquid.rb,
lib/trmnl/liquid/filters.rb,
lib/trmnl/liquid/fallback.rb,
lib/trmnl/liquid/template_tag.rb,
lib/trmnl/liquid/memory_system.rb,
lib/trmnl/liquid/rails_helpers.rb

Overview

Main namespace.

Defined Under Namespace

Modules: Fallback, Filters, RailsHelpers Classes: MemorySystem, TemplateTag

Class Method Summary collapse

Class Method Details

.load(key) ⇒ Object

:reek:TooManyStatements



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/trmnl/liquid.rb', line 12

def self.load key
  case key
    when :rails
      require "trmnl/liquid/rails_helpers"

      require "trmnl/i18n"

      TRMNL::I18n.load_locales
      path = Pathname Gem.loaded_specs["rails-i18n"].full_gem_path
      ::I18n.load_path += path.join("rails/locale").glob("*.yml")
    else fail KeyError, "Unable to load extension due to invalid key: #{key.inspect}."
  end
end

.new(file_system: TRMNL::Liquid::MemorySystem.new) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/trmnl/liquid.rb', line 26

def self.new(file_system: TRMNL::Liquid::MemorySystem.new, **)
  ::Liquid::Environment.build(file_system:, **) do |environment|
    environment.register_filter TRMNL::Liquid::Filters
    environment.register_tag "template", TRMNL::Liquid::TemplateTag
    yield environment if block_given?
  end
end