title: Check if a custom Twig function exists and then call it
body: <p>I test if a custom Twig function exists:</p>
  
  <pre><code>{% if methodExist('sg_datatables_render') %}
      {{ sg_datatables_render(datatable) }}
   {% else %}
      {{ datatable_render((datatable)) }}
  {% endif %}
  </code></pre>
  
  <p><code>methodExist</code> is a simple <code>Twig_Function</code>:</p>
  
  <pre><code> /**
   * @param $name
   * @return bool
   */
  public function methodExist($name){
  
      if($this-&gt;container-&gt;get('twig')-&gt;getFunction($name)){
          return true;
      }else{
          return false;
      }
  }
  </code></pre>
  
  <p>But I get an exception:</p>
  
  <pre><code>Unknown "sg_datatables_render" function. Did you mean "datatable_render"?
  500 Internal Server Error - Twig_Error_Syntax
  </code></pre>