12 def render_liquid page, content
13 liquid self.body, content, page, binding
17 # Render a page's liquid and return the intermediate result
18 def liquid template, content, page, binding = TOPLEVEL_BINDING
19 Liquid::Template.file_system = Liquid::LocalFileSystem.new(File.join(File.dirname(Rake.application().rakefile), "_includes"))
20 unless defined? @liquid_template
21 @liquid_template = Liquid::Template.parse(template)
25 vars["content"] = content
27 vars["site"] = site.config.h.clone
29 site.pages.each do |f, p|
30 pages[f] = p.config.h.clone
31 pages[f]["url"] = p.url
33 vars["site"]["pages"] = pages
35 vars["page"] = page.config.h.clone
36 vars["page"]["url"] = page.url
38 @liquid_template.render(vars)
42 class LiquidCode < Liquid::Include
43 Syntax = /(#{Liquid::QuotedFragment}+)(\s+(?:as)\s+(#{Liquid::QuotedFragment}+))?/o
45 def initialize(tag_name, markup, tokens)
46 Liquid::Tag.instance_method(:initialize).bind(self).call(tag_name, markup, tokens)
53 raise SyntaxError.new("Error in tag 'code' - Valid syntax: include '[code_file]' as '[language]'")
60 partial = load_cached_partial(context)
64 html = CodeRay.scan(partial.root.nodelist.join, @language).div
70 Liquid::Template.register_tag('code', LiquidCode)