29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/asciidoctor-p2e/extension.rb', line 29
def process parent, reader, attrs
lines = reader.lines
data = Tomlrb.parse(lines * "\n")
if attrs.key?('type')
type = attrs['type']
else
type = 'creature'
end
if attrs.key?('role')
data['role'] = attrs['role']
end
extdir = ::File.join(::File.dirname __FILE__)
templates = {
'creature' => "#{extdir}/creatureblock.html.erb",
'item' => "#{extdir}/itemblock.html.erb",
'hazard' => "#{extdir}/hazardblock.html.erb"
}
template = File.read(templates[type])
html = ERB.new(template).result_with_hash(data)
create_pass_block parent, html, attrs, subs: nil
end
|