1
0
Fork 0
This repository has been archived on 2019-12-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
neinomaten/neinomat.lib.rb

29 lines
646 B
Ruby
Raw Normal View History

2006-10-13 18:08:25 +00:00
def parse_template(title, template)
2006-10-13 21:02:35 +00:00
template_re = Regexp.new("\\\{\\\{" + template + "(.*?)\\\}\\\}", Regexp::MULTILINE)
2006-10-13 18:08:25 +00:00
fields = {}
fields_string = @wiki.article(title).text.scan(template_re)[0][0]
inlink = 0
field = ""
fields_string += "|" unless fields_string.match(/\|$/)
fields_string.split(//).each do |c|
if c == "|" && inlink == 0
(key, value) = field.split(/=/)
fields[key] = value
field = ""
else
inlink += 1 if c == "["
inlink -= 1 if c == "]"
field += c
end
end
fields
end
def datum2isodate(datum)
return datum[6..9] + "-" + datum[3..4] + "-" + datum[0..1]
end