Class: Lifer::Builder::HTML::FromLiquid::LiquidEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/lifer/builder/html/from_liquid/liquid_env.rb

Overview

From the ‘liquid` gem’s README:

“In Liquid, a ”Environment“ is a scoped environment that encapsulates custom tags, filters, and other configurations. This allows you to define and isolate different sets of functionality for different contexts, avoiding global overrides that can lead to conflicts and unexpected behavior.”

For Lifer, we simply use a single global environment for each build.

Class Method Summary collapse

Class Method Details

.globalLifer::Environment

Returns the global Liquid environment that contains all local templates, custom tags, and filters.

Returns:

  • (Lifer::Environment)


17
18
19
20
21
22
23
24
25
26
# File 'lib/lifer/builder/html/from_liquid/liquid_env.rb', line 17

def self.global
  Liquid::Environment.build do |environment|
    environment.error_mode = :strict

    environment.file_system =
      Liquid::LocalFileSystem.new(Lifer.root, "%s.html.liquid")

    environment.register_filter Lifer::Builder::HTML::FromLiquid::Filters
  end
end