Sha256: 2bdda0e718d54e8a087a5e9b0e1d26255302a51a1ef03b31f6b2180dea92ed91
Contents?: true
Size: 851 Bytes
Versions: 12
Compression:
Stored size: 851 Bytes
Contents
require "yaml" require "tilt" module Machined module Processors class FrontMatterProcessor < Tilt::Template # The Regexp that separates the YAML # front matter from the content. FRONT_MATTER_PARSER = / ( \A\s* # Beginning of file ^---\s*$\n* # Start YAML Block (.*?)\n* # YAML data ^---\s*$\n* # End YAML Block ) (.*)\Z # Rest of File /mx # See `Tilt::Template#prepare`. def prepare end # See `Tilt::Template#evaluate`. def evaluate(context, locals = {}, &block) output = data if FRONT_MATTER_PARSER.match data locals = YAML.load $2 context.locals = locals if locals output = $3 end output end end end end
Version data entries
12 entries across 12 versions & 1 rubygems