Class: Jekyll::EmailMunge::MungeEmailScriptTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-email-munge/munge_email_script_tag.rb

Overview

munge_email_script %

Emits the inline <script> that decrypts munge_email % payloads on click. Call this once per page (typically just before </body> in your default layout). It reads email_munge.key_hex from _config.yml and bakes it into the script — that key is intentionally public; the goal is defeating scrapers, not hiding the address from a determined human.

Constant Summary collapse

DECODER_PATH =
File.expand_path("decoder.js", __dir__).freeze

Instance Method Summary collapse

Instance Method Details

#render(context) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/jekyll-email-munge/munge_email_script_tag.rb', line 13

def render(context)
  key_hex = context.registers[:site].config.dig("email_munge", "key_hex")
  unless key_hex
    raise "jekyll-email-munge: email_munge.key_hex missing in _config.yml"
  end

  js = decoder_source.gsub("__KEY_HEX__", key_hex)
  %(<script>#{js}</script>)
end