db_and_tools/render.rb
# we avoid building an intermediate data structure, and instead just expose an
# interface for the template to directly query the rdf view
we avoid building an intermediate data structure, and instead just expose an
interface for the template to directly query the rdf view
we avoid building an intermediate data structure and instead just expose an interface for the template to directly query the rdf view
def render( filename )
    processed = false
    result = ""
    [ filename, "templates/#{filename}"].each do |path|
      if File.exists?( path)
        s = ERB.new( File.read(path)).result(binding)
        s = s.gsub /^[ \t]*$\n/, ''
        result += s
        processed = true
        break
      end
    end
    if !processed
      raise "Could not find template '#{filename}'!"
    end
    result
  end
def render ( filename ) processed = false result = "" [ filename , "templates/#{filename}" ] . each do | path | if File . exists? ( path ) s = ERB . new ( File . read ( path ) ) . result ( binding ) s = s . gsub / ^[  \t ]*$ \n / , '' result += s processed = true break end end if ! processed raise "Could not find template '#{filename}'!" end result end
we avoid building an intermediate data structure, and instead just expose an
interface for the template to directly query the rdf view
we avoid building an intermediate data structure and instead just expose an interface for the template to directly query the rdf view
# we need to use string temporaries, rather than output stream in order to get # proper sequencing in the recursive expansion of nested templates # puts "opening #{path}"
filename