日期:2014-05-16  浏览次数:20625 次

【模板】script的type属性为x-tmpl,怎样分离出这部分代码单独写模板文件
原代码如下:
<script id="template-upload" type="text/x-tmpl">
              {% for (var i=0, file; file=o.files[i]; i++) { %}
                  <tr class="template-upload fade">
                      <td class="preview"><span class="fade"></span></td>
                      <td class="name"><span>{%=file.name%}</span></td>
                      <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
                      {% if (file.error) { %}
                          <td class="error" colspan="2"><span class="label label-important">Error</span> {%=file.error%}</td>
                      {% } else if (o.files.valid && !i) { %}
                          <td>
                              <div class="progress progress-success progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><div class="bar" style="width:0%;"></div></div>
                          </td>
                          <td class="start">{% if (!o.options.autoUpload) { %}
                              <button class="btn">