503
* Render a specific template
504
* @param template The template
505
* @param args The template data
507
protected static void renderTemplate(Template template, Object... args) {
509
Scope.RenderArgs templateBinding = Scope.RenderArgs.current();
510
for (Object o : args) {
511
List<String> names = LocalVariablesNamesTracer.getAllLocalVariableNames(o);
512
for (String name : names) {
513
templateBinding.put(name, o);
516
templateBinding.put("session", Scope.Session.current());
517
templateBinding.put("request", Http.Request.current());
518
templateBinding.put("flash", Scope.Flash.current());
519
templateBinding.put("params", Scope.Params.current());
521
templateBinding.put("errors", Validation.errors());
522
} catch (Exception ex) {
523
throw new UnexpectedException(ex);
527
throw new TemplateNotFoundException("");
529
throw new RenderTemplate(template, templateBinding.data);
530
} catch (TemplateNotFoundException ex) {
531
if(ex.isSourceAvailable()) {
534
StackTraceElement element = PlayException.getInterestingStrackTraceElement(ex);
535
if (element != null) {
536
throw new TemplateNotFoundException(template.name, Play.classes.getApplicationClass(element.getClassName()), element.getLineNumber());
503
544
* Render the corresponding template
504
545
* @param args The template data