Class: Yass::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/yass/renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Renderer

Returns a new instance of Renderer.



5
# File 'lib/yass/renderer.rb', line 5

def initialize(source) = @source = source

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



3
4
5
# File 'lib/yass/renderer.rb', line 3

def source
  @source
end

Instance Method Details

#render(outfile = source.site.dest_dir.join(source.src_path), content = source.content, layout: true) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/yass/renderer.rb', line 7

def render(outfile = source.site.dest_dir.join(source.src_path), content = source.content, layout: true)
  case outfile.extname
  when ".md"
    content = Kramdown::Document.new(content, input: "GFM").to_html
    return render(outfile.sub(/\.md$/, ".html"), content, layout: layout)
  when ".liquid"
    template = LiquidTemplate.compile(source.site, source.src_path, content)
    content = template.render(source)
    return render(outfile.sub(/\.liquid$/, ""), content, layout: layout)
  else
    return content if source.layout.nil? || !layout
    return source.layout.render(source) { content }
  end
end