【问题标题】:Please help me converting this code to haml请帮我将此代码转换为haml
【发布时间】:2014-12-12 22:33:10
【问题描述】:

注意: 我正在尝试将文件上传系统包含在我的 rails 项目中。但是我遇到了这个 EJS 代码的问题。请帮我把下面的代码转换成HAML代码。

<script id="b-file-ejs" type="text/ejs">
            <div id="file-<%=FileAPI.uid(file)%>" class="js-file b-file b-file_<%=file.type.split('/')[0]%>">
                <div class="js-left b-file__left">
                    <img src="<%=icon[file.type.split('/')[0]]||icon.def%>" width="32" height="32" style="margin: 2px 0 0 3px"/>
                </div>
                <div class="b-file__right">
                    <div><a class="js-name b-file__name"><%=file.name%></a></div>
                    <div class="js-info b-file__info">size: <%=(file.size/FileAPI.KB).toFixed(2)%> KB</div>
                    <div class="js-progress b-file__bar" style="display: none">
                        <div class="b-progress"><div class="js-bar b-progress__bar"></div></div>
                    </div>
                </div>
                <i class="js-abort b-file__abort" title="abort">&times;</i>
            </div>
        </script>



【问题讨论】:

  • @apneadiving 它不起作用。假设 ejs 的 到 ruby​​ 的 。我需要其他方法来转换代码

标签: ruby-on-rails jquery-file-upload ejs


【解决方案1】:

你也可以试试这个工具,有时效果更好: http://www.htmltohaml.com/

【讨论】:

    【解决方案2】:

    您是否尝试过使用以下 gem haml_ejs

    查看这个github链接https://github.com/duncanbeevers/haml-ejs

    【讨论】:

    • 是的,我正在使用这个 gem。但我不知道如何在 ejs 中使用该变量。我想使用类中的值和 id code" width="32" height="32" style="margin: 2px 0 0 3px"/> code
    【解决方案3】:

    您可以使用以下链接将 HTML 转换为 HAML

    http://html2haml.heroku.com/

    【讨论】:

    • 此链接已作为评论放置,并且 OP 已经表示他想要一种替代方法
    猜你喜欢
    • 2015-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-14
    • 1970-01-01
    • 1970-01-01
    • 2020-11-07
    • 2019-05-28
    相关资源
    最近更新 更多