mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-10-31 23:35:00 -04:00
added a raw option to render_partial. Now you can import partials without having them parsed by the Liquid template parser
This commit is contained in:
parent
70d2c83843
commit
40b444c9cd
@ -26,9 +26,14 @@ require 'pathname'
|
|||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class RenderPartialTag < Liquid::Tag
|
class RenderPartialTag < Liquid::Tag
|
||||||
def initialize(tag_name, file, tokens)
|
def initialize(tag_name, markup, tokens)
|
||||||
|
@file = nil
|
||||||
|
@raw = false
|
||||||
|
if markup =~ /^(\S+)\s?(\w+)?/
|
||||||
|
@file = $1.strip
|
||||||
|
@raw = $2 == 'raw'
|
||||||
|
end
|
||||||
super
|
super
|
||||||
@file = file.strip
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
@ -45,9 +50,13 @@ module Jekyll
|
|||||||
if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m
|
if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m
|
||||||
contents = $1.lstrip
|
contents = $1.lstrip
|
||||||
end
|
end
|
||||||
partial = Liquid::Template.parse(contents)
|
if @raw
|
||||||
context.stack do
|
contents
|
||||||
partial.render(context)
|
else
|
||||||
|
partial = Liquid::Template.parse(contents)
|
||||||
|
context.stack do
|
||||||
|
partial.render(context)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user