Class: Sitepress::AssetTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/sitepress/asset_template.rb

Overview

Since we use Frontmatter, we have to do some parsing to get a Tilt template working properly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset) ⇒ AssetTemplate

Returns a new instance of AssetTemplate.



9
10
11
# File 'lib/sitepress/asset_template.rb', line 9

def initialize(asset)
  @asset = ceorce_asset(asset)
end

Instance Attribute Details

#assetObject (readonly)

Returns the value of attribute asset.



7
8
9
# File 'lib/sitepress/asset_template.rb', line 7

def asset
  @asset
end

Instance Method Details

#render(*args, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/sitepress/asset_template.rb', line 13

def render(*args, &block)
  if renderable_resource?
    template.render(*args, &block)
  else
    asset.body
  end
end

#templateObject



21
22
23
# File 'lib/sitepress/asset_template.rb', line 21

def template
  @_template ||= engine.new{ asset.body }
end