Calling templates with dynamic names

27 views
Skip to first unread message

Tõnis Ostrat

unread,
Sep 13, 2016, 2:19:43 PM9/13/16
to Closure Templates Discuss
Is there a way to dynamically determine the name of a template based on a wrapper template attribute (without a massive if-else spaghetti chain)?

Something like the following
{namespace foo}

/*
 * @param name
 */

{template .wrapper}
 
//something before
 
{call foo.{$name} /}
  //something after
{/template}

instead of

{namespace foo}

/*
 * @param name
 */

{template .wrapper}
 
//something before
 
{if $name == 'bar'}
   
{call foo.bar /}
 
{elseif $name == 'baz'}
   
{call foo.baz /}
 
{else}
    //donothing
 
{/if}
  /
/something after
{/template}


Luke Sandberg

unread,
Sep 13, 2016, 2:53:18 PM9/13/16
to Closure Templates Discuss

--

---
You received this message because you are subscribed to the Google Groups "Closure Templates Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-templates-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages