14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/snippr/meta_data.rb', line 14
def self.(name, content, snippet=nil)
if content =~ /^(---\s*\n.*?\n?)^(---\s*$?)/m
content = Regexp.last_match.post_match.strip
meta = yaml_load(name, $1)
if meta
if meta.keys.include?(INCLUDE)
Array(meta[INCLUDE]).each do |include_path|
if (snippet && include_path.start_with?("./"))
include_path = snippet.name.gsub(/\/.*?$/,"") + "/" + include_path.gsub(/^\.\//, "")
end
snippet = Snippr.load(include_path)
meta = deep_yaml_merge(snippet.meta, meta)
end
end
end
end
meta = meta ? meta : {}
[content, meta]
end
|