<%! from django.utils.translation import ugettext as _ %>
<%namespace name='static' file='../static_content.html'/>

<%
  import hashlib
  import copy
  import json
  hlskey = hashlib.md5(module.location.url()).hexdigest()
%>

## js templates
<script id="metadata-editor-tpl" type="text/template">
    <%static:include path="js/metadata-editor.underscore" />
</script>

<script id="metadata-number-entry" type="text/template">
    <%static:include path="js/metadata-number-entry.underscore" />
</script>

<script id="metadata-string-entry" type="text/template">
    <%static:include path="js/metadata-string-entry.underscore" />
</script>

<script id="metadata-option-entry" type="text/template">
    <%static:include path="js/metadata-option-entry.underscore" />
</script>

<script id="metadata-list-entry" type="text/template">
    <%static:include path="js/metadata-list-entry.underscore" />
</script>

<% showHighLevelSource='source_code' in editable_metadata_fields and editable_metadata_fields['source_code']['explicitly_set'] and enable_latex_compiler %>
<% metadata_field_copy = copy.copy(editable_metadata_fields) %>
## Delete 'source_code' field (if it exists) so metadata editor view does not attempt to render it.
% if 'source_code' in editable_metadata_fields:
    ## source-edit.html needs access to the 'source_code' value, so delete from a copy.
    <% del metadata_field_copy['source_code'] %>
% endif

% if showHighLevelSource:
    <div class="launch-latex-compiler">
      <a href="#hls-modal-${hlskey}" id="hls-trig-${hlskey}">${_("Launch Latex Source Compiler")}</a>
    </div>
    <%include file="source-edit.html" />
% endif

<div class="wrapper-comp-settings metadata_edit" id="settings-tab" data-metadata='${json.dumps(metadata_field_copy) | h}'/>
