collection-renderer-lib/resources/collection_preview/bootstrap.rb
# Takes a Java InputStream to an ERB template and a map of variables to pass to the template.
# Renders the ERB template returning the generating content string.
Takes a Java InputStream to an ERB template and a map of variables to pass to the template.
Renders the ERB template returning the generating content string.
Takes a Java InputStream to an ERB template and a map of variables to pass to the template . Renders the ERB template returning the generating content string .
def java_render(template_input_stream, variables)
  context = OpenStruct.new(variables).instance_eval do
    variables.each do |k, v|
      instance_variable_set(k, v) if k[0] == '@'
    end
    @current_user = OpenStruct.new()
    def partial(partial_name, options={})
      new_variables = marshal_dump.merge(options[:locals] || {})
      Java::Pavo::ERB.render(partial_name, new_variables)
    end
    binding
  end
  ERB.new(template_input_stream.to_io.read).result(context);
end
def java_render ( template_input_stream , variables ) context = OpenStruct . new ( variables ) . instance_eval do variables . each do | k , v | instance_variable_set ( k , v ) if k [ 0 ] == '@' end @current_user = OpenStruct . new ( ) def partial ( partial_name , options = { } ) new_variables = marshal_dump . merge ( options [ :locals ] || { } ) Java :: Pavo :: ERB . render ( partial_name , new_variables ) end binding end ERB . new ( template_input_stream . to_io . read ) . result ( context ) ; end
Takes a Java InputStream to an ERB template and a map of variables to pass to the template.
Takes a Java InputStream to an ERB template and a map of variables to pass to the template .
# MMT ERBs expect a current user
template_input_stream
<not_specific>
variables
<not_specific>