1
0
mirror of https://github.com/tabler/tabler.git synced 2025-12-22 09:54:24 +04:00
Files
tabler/pages/_plugins/jekyll-capture.rb
2019-10-25 19:12:31 +02:00

39 lines
774 B
Ruby

module Jekyll
module Tags
class CaptureGlobal < Liquid::Block
def initialize(tag_name, text, tokens)
super
@text = text.strip
end
def render(context)
if $capture_global[@text] === nil
$capture_global[@text] = '';
end
$capture_global[@text] += super.strip + "\n\n"
''
end
end
end
Jekyll::Hooks.register :site, :after_init do |page, jekyll|
$capture_global = {}
end
Jekyll::Hooks.register :pages, :pre_render do |page, jekyll|
jekyll.site['capture_global'] = $capture_global
end
Jekyll::Hooks.register :pages, :post_render do |page, jekyll|
$capture_global = {}
end
end
Liquid::Template.register_tag('capture_global', Jekyll::Tags::CaptureGlobal)