Class: Metatext
- Inherits:
-
Object
- Object
- Metatext
- Defined in:
- lib/metatext.rb
Overview
MetaText a lightweight jekyll-style metadata parser
- what it do
-
parses yaml at the top of any file, jekyll style
-
stores metadata in an object
-
inject your own text processor (e.g. redcarpet for markdown)
-
use erb (<% %>) for dynamic text on demand
Class Method Summary collapse
- .configure(dir: nil, ext: nil, processor: nil) ⇒ Object
-
.parse(to_parse, locals = {}) {|metadata(raw), render(raw)| ... } ⇒ Object
main driver method for metatext parsing.
Class Method Details
.configure(dir: nil, ext: nil, processor: nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/metatext.rb', line 24 def configure(dir: nil, ext: nil, processor: nil) @dir = dir @ext = ext @pro = processor end |
.parse(to_parse, locals = {}) {|metadata(raw), render(raw)| ... } ⇒ Object
main driver method for metatext parsing
33 34 35 36 37 |
# File 'lib/metatext.rb', line 33 def parse(to_parse, locals={}) raw = read(to_parse) || to_parse raw = erbify raw, with: locals if parse_as_erb? raw yield (raw), render(raw) end |