Class: Tilt::YamlFrontMattersLiquidTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/locomotive/mounter/extensions/tilt/liquid.rb

Overview

YAML Front-matters for Liquid templates

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Template

#need_for_prerendering?

Instance Attribute Details

#attributesObject (readonly)

Attributes from YAML Front-matters header



7
8
9
# File 'lib/locomotive/mounter/extensions/tilt/liquid.rb', line 7

def attributes
  @attributes
end

Instance Method Details

#prepareObject



9
10
11
12
13
14
15
16
# File 'lib/locomotive/mounter/extensions/tilt/liquid.rb', line 9

def prepare
  if data =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)(.*)/m
    @attributes = YAML.load($1)
    @data = $3
  end
  @data = @data.force_encoding('utf-8')
  # Note: do not call 'super' because we are going to use a different parse mechanism
end