AngelDoReMi / closure-templates

Automatically exported from code.google.com/p/closure-templates
Apache License 2.0
0 stars 0 forks source link

Allow expression as the callee name of a {call/} command #23

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
A useful feature to have is to allow using expression as callee template name 
of a {call /} command.

For example, it would be nice to be able to do the following:

{foreach $field in $form.fields}
  {call $field.widgetTemplate}
    {param field:$field}
  {/call}
{/foreach}

This allows users of the template library to dynamically configure which 
template to use for rendering some sub-portion of the main template. For 
example, I can then automatically render a form with different input fields 
based on a richly annotated java class, using a simple foreach loop like above 
in the main template.

This functionality can be emulated by having a big switch command, or simply 
rendering the desired sub-template and supplying it as argument to the main 
template. However, the first solution is not extensible while the second 
solution incurs performance overhead because of the extra string copying.

Original issue reported on code.google.com by yuanchen...@gmail.com on 10 Jul 2010 at 12:16

GoogleCodeExporter commented 8 years ago
This is really an Enhancement request, but I'm not sure how to change the 
request type...

Original comment by yuanchen...@gmail.com on 10 Jul 2010 at 12:17

GoogleCodeExporter commented 8 years ago
Changed to Enhancement type.

Original comment by kai.hu...@gmail.com on 12 Jul 2010 at 2:38

GoogleCodeExporter commented 8 years ago

Original comment by kai.hu...@gmail.com on 19 Jul 2010 at 7:44

GoogleCodeExporter commented 8 years ago
This would require a deep change in the compiler. It would change a lot of 
assumptions and break a lot of compiler passes. The gain is not worth the cost, 
so we do not plan to add this feature.

Original comment by kai.hu...@gmail.com on 25 Oct 2010 at 10:30