<% # You can't make a static site generator much more basic than this. # YAML comes in, HTML comes out. Deal with it. require 'yaml' require 'uri' include ERB::Util $rich_data_keys = ['Description', 'Installation'] datasheetPath = (ENV['CONTENT'] || 'datasheet.yaml') data = YAML.load_file(datasheetPath) def qndMarkdown2HTML(mdString) result = '' IO.popen(["markdown", "--html5", "-f", "FENCEDCODE", "-s", mdString]) {|out| result = out.read} return result end def hashList(theHash) result = '' result += '' return result end def arrayList(theArray) result = '' result += '
    ' theArray.each do |value| result += '
  1. ' + renderAny(value) + '
  2. ' end result += '
' return result end def renderAny(thing, context=nil) result = '' case thing when Hash result += hashList(thing) when Array result += arrayList(thing) when String if ($rich_data_keys.include?(context)) result += qndMarkdown2HTML(thing) elsif (thing =~ /^http/) == 0 result += %Q(#{h(thing)}) else result += h(thing) end else STDERR.puts "What is this?", thing.class result += h(thing.to_s) end return result end %> <%= renderAny(data) %>