{% include "snippetMacros.html" %}

{% macro renderMapLocations(items, pageUrl, classname) %}
  {% if items %}
    {% for item in items %}
      {{ renderMapLocation(item, pageUrl, classname) }}
    {% endfor %}
  {% else %}
    <h4>There are no map locations yet.</h4>
  {% endif %}
{% endmacro %}

{% macro renderMapLocation(item, pageUrl, classname) %}
  <li class="apos-location {{classname}} {{item.locType}}" id="{{item._id}}">
    <!-- <a href="{{ pageUrl }}/{{ item.slug }}">{{ item.title | e }}</a> -->
    <a>{{ item.title | e }}</a>
  </li>
{% endmacro %}

{% macro renderGoogleMap(items, options={}) %}
  {# create an element for the map to load in REMEMBER TO SET THE D#}
  {# REMEMBER TO SET THE WIDTH IN YOUR STYLESHEETS OR YOU WON'T SEE ANYTHING #}
  {# Allow the ID to be passed in as an option. -Tom #}
  {% set id = options.id %}
  {% if not id %}
    {% set id = 'apos-map-canvas' %}
  {% endif %}
  <div id="{{ id }}"></div>

  {# load in the google maps apis #}
  {# instantiate a new AposGoogleMap #}
  <script type="text/javascript">
    window.gmap = new AposGoogleMap({{ items | json }}, {{ options | json }});
  </script>
{% endmacro %}

{% include "snippetMacros.html" %}

{% macro renderMapLocations(items, pageUrl, classname) %}
  {% if items %}
    {% for item in items %}
      {{ renderMapLocation(item, pageUrl, classname) }}
    {% endfor %}
  {% else %}
    <h4>There are no map locations yet.</h4>
  {% endif %}
{% endmacro %}

{% macro renderMapLocation(item, pageUrl, classname) %}
  <li class="apos-location {{classname}} {{item.locType}}" id="{{item._id}}">
    <!-- <a href="{{ pageUrl }}/{{ item.slug }}">{{ item.title | e }}</a> -->
    <a>{{ item.title | e }}</a>
  </li>
{% endmacro %}

{% macro renderGoogleMap(mapItems, mapOptions={}) %}
  {# create an element for the map to load in REMEMBER TO SET THE D#}
  {# REMEMBER TO SET THE WIDTH IN YOUR STYLESHEETS OR YOU WON'T SEE ANYTHING #}
  {# Allow the ID to be passed in as an option. -Tom #}
  {% set id = mapOptions.id %}
  {% if not id %}
    {% set id = 'apos-map-canvas' %}
  {% endif %}
  <div id="{{ id }}"></div>

  {# load in the google maps apis #}
  {# instantiate a new AposGoogleMap #}
  <script type="text/javascript">
    window.gmap = new AposGoogleMap({{ mapItems | json }}, {{ mapOptions | json }});
  </script>
{% endmacro %}

Work around a nunjucks bug: if a variable already exists in the calling scope, it masks a macro parameter of the same name, so what you passed for that option is ignored in favor of the variable in the outer scope. ): Ow. Will create a test case and report
Work around a nunjucks bug: if a variable already exists in the calling scope, it masks a macro parameter of the same name, so what you passed for that option is ignored in favor of the variable in the outer scope. ): Ow. Will create a test case and report
