title: How can I indirectly call a macro in a Jinja2 template?
body: <p>I'm trying to do something like this:</p>
  
  <pre><code>{% macro obj_type_1 %}
  stuff
  {% endmacro %}
  {% macro obj_type_2 %}
  stuff
  {% endmacro %}
  
  {{ (obj|get_type)(obj) }}
  </code></pre>
  
  <p>In this example, <code>get_type</code> is a filter that would return <code>obj_type_1</code> or <code>obj_type_2</code> -- ie, the name of the macro to call for <code>obj</code>. I don't want to mark up <code>obj</code> with configuration output because right now <code>obj</code> is used in several templates as structural data, to be rendered with different markup depending on the context.</p>
  
  <p>I know the syntax here is a bit tortured, but I think that's because what I want to do isn't immediately possible in Jinja templates. I'm trying to replace a big damn schwack of if/elif/else crap in some config generation code with templates, but this bit seems to be a sticking point.</p>