-
Notifications
You must be signed in to change notification settings - Fork 1
/
inspector.rb
28 lines (24 loc) · 869 Bytes
/
inspector.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'json'
module Jekyll
class InspectTag < Liquid::Tag
def initialize(tag_name, markup, tokens)
super
end
def render(context)
output = <<-eos
\<script type='text/javascript'>
function LiquidInspector(inspectedValues){
this.context = inspectedValues\;
}
var data = {'environments':#{context.environments.to_json.gsub('"', "\"").gsub( '</', '<\/' )},
'errors':#{context.errors.to_json.gsub('"', "\"").gsub( '</', '<\/' )},
'scopes':#{context.scopes.to_json.gsub('"', "\"").gsub( '</', '<\/' )},
'registers':#{context.registers.to_json.gsub('"', "\"").gsub( '</', '<\/' )} }\;
console.log(new LiquidInspector(data))\;
\<\/script\>
eos
output
end
end
end
Liquid::Template.register_tag('inspect', Jekyll::InspectTag)