{% import "lib/macros.html" as lib -%}
{% extends "api/api.template.html" %}

{% block additional %}
  <h2 id="{$ doc.name $}-info">Directive Info</h2>
  <ul>
    {% if doc.scope %}<li>This directive creates new scope.</li>{% endif %}
    <li>This directive executes at priority level {$ doc.priority $}.</li>
    {% if doc.multiElement %}<li>This directive can be used as {@link $compile#-multielement- multiElement}</li>{% endif %}
  </ul>

  {% block usage %}
  <h2 id="usage">Usage</h2>
  <div class="usage">
  {% if doc.usage %}
    {$ doc.usage | marked $}
  {% else %}
    <ul>
    {% if doc.restrict.element %}
      <li>as element:
      {% code %}
      <{$ doc.name | dashCase $}
        {%- for param in doc.params %}
        {$ lib.directiveParam(param.alias or param.name, param.type, '="', '"') $}
        {%- endfor %}>
      ...
      </{$ doc.name | dashCase $}>
      {% endcode %}
      </li>
    {% endif -%}


    {% set hasNameAsParam = false %}

    {# when a directive's name is not a parameter (i.e. doesn't take a value),
      add the directive name to the list of attributes and/or css classes #}

    {%- for param in doc.params %}
    {% set hasNameAsParam = true if param.name === doc.name else hasNameAsParam %}
    {%- endfor %}

    {%- if doc.restrict.attribute -%}
      <li>as attribute:
        {% code %}
        <{$ doc.element $}
          {%- if not hasNameAsParam %}
          {$ lib.directiveParam(doc.name, {}, '', '') $}
          {%- endif -%}
          {%- for param in doc.params %}
          {$ lib.directiveParam(param.name, param.type, '="', '"') $}
          {%- endfor %}>
        ...
        </{$ doc.element $}>
        {% endcode %}
      </li>
    {% endif -%}

    {%- if doc.restrict.cssClass -%}

      <li>as CSS class:
        {% code %}
        {% set sep = joiner(' ') %}
        <{$ doc.element $} class="
        {%- if not hasNameAsParam -%}
          {$ sep() $}{$ lib.directiveParam(doc.name, {}, '', '') $}
        {%- endif -%}
        {%- for param in doc.params -%}
          {$ sep() $}{$ lib.directiveParam(param.name, param.type, ': ', ';') $}
        {%- endfor %}"> ... </{$ doc.element $}>
        {% endcode %}
      </li>
    {% endif -%}

  {%- endif %}
  </div>
  {% endblock -%}

  {% include "lib/params.template.html" %}
  {% include "lib/events.template.html" %}

  {%- if doc.animations %}
  <h2 id="animations">Animations</h2>
  {$ doc.animations | marked $}
  {$ 'module:ngAnimate.$animate' | link('Click here', doc) $} to learn more about the steps involved in the animation.
  {%- endif -%}
{% endblock %}
