Class: WhatTheGem::Template

Inherits:
Liquid::Template
  • Object
show all
Defined in:
lib/whatthegem/template.rb

Defined Under Namespace

Modules: Filters

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(src) ⇒ Object



34
35
36
# File 'lib/whatthegem/template.rb', line 34

def self.parse(src)
  new.parse(src.chomp.gsub(/\n *({%.+?%})\n/, "\\1\n"))
end

Instance Method Details

#parse(src) ⇒ Object



38
39
40
# File 'lib/whatthegem/template.rb', line 38

def parse(src)
  super(src, error_mode: :strict)
end

#render(data, **options) ⇒ Object Also known as: call



42
43
44
# File 'lib/whatthegem/template.rb', line 42

def render(data, **options)
  super(Hm.(data).transform_keys(&:to_s).to_h, filters: [Filters], **options)
end

#to_procObject



48
49
50
51
# File 'lib/whatthegem/template.rb', line 48

def to_proc
  # proc { |data| render(data) }
  method(:call).to_proc
end