django中tag,附代码如下,这段程序的意思是做什么

from django import template

register = template.Library()

@register.simple_tag
def upload_js():
    return """
<!-- The template to display files available for upload -->
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-upload fade">
        <td width="50%">
            <p class="name ellipsis" title="{%=file.relative_path || file.name%}">
            {%=file.relative_path || file.name%}
            </p>
            <p class="error ellipsis"></p>
        </td>
        <td width="30%">
            <span class="size"></span>
            <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
        </td>
        <td width="20%">
            {% if (!o.options.autoUpload) { %}
            <button class="btn btn-success start" disabled>
                <span>{%=locale.fileupload.start%}</span>
            </button>
            {% } %}
            {% if (!i) { %}
            <button class="btn btn-warning cancel">
                <span>{%=locale.fileupload.cancel%}</span>
            </button>
            {% } %}
        </td>
    </tr>
{% } %}
</script>
<!-- The template to display files after upload -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
    <tr class="template-download fade">
        <td width="50%">
            <p class="name ellipsis" title="{%=file.relative_path || file.name%}">
            {%=file.relative_path || file.name%}
            </p>
            <p class="error ellipsis">{% if (file.error) { %}{%=file.error%}{% } %}</p>
        </td>
        <td width="30%">
            <span class="size">{%=o.formatFileSize(file.size)%}</span>
        </td>
        <td width="20%">
            <span class="tip">
            {% if (file.canceled) { %}
                {%=locale.fileupload.canceled%}
            {% } %}
            {% if (file.uploaded) { %}
                {%=locale.fileupload.uploaded%}
            {% } %}
            </span>
        </td>
    </tr>
{% } %}
</script>
"""
阅读 1.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题