Rails: Amazon s3直接上传

Rails: Amazon s3 direct upload

我正在学习本教程:http://blog.littleblimp.com/post/53942611764/direct-uploads-to-s3-with-rails-paperclip-and

我对我在下面脚本标记之间发布的代码块感到非常困惑。据我所知,javascript 应该放在脚本标签之间,但作者却放了 HTML。我的 sublime 编辑器似乎同意我的看法,因为它对脚本标签之间的所有 HTML 进行了着色(不是通常的标记颜色)。我认为这部分代码应该提供一个 "upload" 按钮,但是当我尝试通过本地主机加载页面时,什么也没有出现。有人可以通过在脚本标签之间放置 HTML 来告诉我作者在做什么,并告诉我如何让代码工作吗?

非常感谢(P.S。我是 ​​Rails 的新手,所以如果我遗漏了一些明显的东西,我深表歉意)。

<div id="uploads_container"></div>
<script id="template-upload" type="text/x-tmpl">
<div id = "upload_{%=o.unique_id%}" class="upload">
<h5>{%=o.name%}</h5>
<div class="progress progress-striped active"><div class="bar" style="width: 0%"></div></div>
</div>
</script>

Could someone please tell me what the author is doing by putting HTML in-between the script tags and also tell me how to get the code to work?

此代码块旨在用作本教程使用的任何 JavaScript 模板库的模板。

某处,将有一大块 JavaScript 代码查找 ID 为 template-upload 的脚本,用必要的值填充占位符(即 {}),然后将输出附加到 DOM.