twitter / hogan.js

A compiler for the Mustache templating language
http://twitter.github.io/hogan.js
Apache License 2.0
5.14k stars 431 forks source link

Hulk and UTF-8 on Windows 10 #259

Closed NatoBoram closed 3 years ago

NatoBoram commented 6 years ago

Hello! I think Hulk has an encoding problem on Windows. The problem doesn't exist on Linux. Input is UTF-8.

It would be best if Hulk didn't make any kind of transformation to the text.

Mise actuelle :
Achat immédiat :
Enchères :
Mise actuelle :
Achat imm├®diat :
Enchères :

Logs

Input

{{#items}}
<div class="row market-item border rounded bg-light" colour="{{data-wearableitemid}}">
    <div class="col-xl-2 col-lg-2 col-md-2 col-sm-3 col-6">
        <img src="{{abstract-icon}}" class="img-fluid rounded">
    </div>
    <div class="col-xl-4 col-lg-4 col-md-4 col-sm-3 col-6 abstract align-middle">
        <span class="align-middle">
            <h5 class="abstract-name btn-link text-dark">{{abstract-name}}</h5>
            <h6 class="abstract-type btn-link text-dark">{{abstract-type}}</h6>
        </span>
    </div>
    <div class="col-xl-4 col-lg-4 col-md-4 col-sm-4 col-8">
        <div class="currentPrice">Mise actuelle : {{currentPrice}}</div>
        <div class="buyNowPrice">Achat immédiat : {{buyNowPrice}}</div>
        <div class="data-bids">Enchères : {{data-bids}}</div>
    </div>
    <div class="col-xl-2 col-lg-2 col-md-2 col-sm-2 col-4 z-score">
        <div class="zscore-currentPrice">{{zscore-currentPrice}}</div>
        <div class="zscore-buyNowPrice">{{zscore-buyNowPrice}}</div>
        <div class="zscore-data-bids">{{zscore-data-bids}}</div>
    </div>
</div>
{{/items}}

Command

hulk .\mustache\* > .\js\templates.js

Output

if (!!!templates) var templates = {};
templates["market"] = new Hogan.Template({
    code: function (c, p, i) {
        var t = this;
        t.b(i = i || "");
        if (t.s(t.f("items", c, p, 1), c, p, 0, 10, 1033, "{{ }}")) {
            t.rs(c, p, function (c, p, t) {
                t.b("<div class=\"row market-item border rounded bg-light\" colour=\"");
                t.b(t.v(t.f("data-wearableitemid", c, p, 0)));
                t.b("\">\r");
                t.b("\n" + i);
                t.b("   <div class=\"col-xl-2 col-lg-2 col-md-2 col-sm-3 col-6\">\r");
                t.b("\n" + i);
                t.b("       <img src=\"");
                t.b(t.v(t.f("abstract-icon", c, p, 0)));
                t.b("\" class=\"img-fluid rounded\">\r");
                t.b("\n" + i);
                t.b("   </div>\r");
                t.b("\n" + i);
                t.b("   <div class=\"col-xl-4 col-lg-4 col-md-4 col-sm-3 col-6 abstract align-middle\">\r");
                t.b("\n" + i);
                t.b("       <span class=\"align-middle\">\r");
                t.b("\n" + i);
                t.b("           <h5 class=\"abstract-name btn-link text-dark\">");
                t.b(t.v(t.f("abstract-name", c, p, 0)));
                t.b("</h5>\r");
                t.b("\n" + i);
                t.b("           <h6 class=\"abstract-type btn-link text-dark\">");
                t.b(t.v(t.f("abstract-type", c, p, 0)));
                t.b("</h6>\r");
                t.b("\n" + i);
                t.b("       </span>\r");
                t.b("\n" + i);
                t.b("   </div>\r");
                t.b("\n" + i);
                t.b("   <div class=\"col-xl-4 col-lg-4 col-md-4 col-sm-4 col-8\">\r");
                t.b("\n" + i);
                t.b("       <div class=\"currentPrice\">Mise actuelle : ");
                t.b(t.v(t.f("currentPrice", c, p, 0)));
                t.b("</div>\r");
                t.b("\n" + i);
                t.b("       <div class=\"buyNowPrice\">Achat imm├®diat : ");
                t.b(t.v(t.f("buyNowPrice", c, p, 0)));
                t.b("</div>\r");
                t.b("\n" + i);
                t.b("       <div class=\"data-bids\">Enchères : ");
                t.b(t.v(t.f("data-bids", c, p, 0)));
                t.b("</div>\r");
                t.b("\n" + i);
                t.b("   </div>\r");
                t.b("\n" + i);
                t.b("   <div class=\"col-xl-2 col-lg-2 col-md-2 col-sm-2 col-4 z-score\">\r");
                t.b("\n" + i);
                t.b("       <div class=\"zscore-currentPrice\">");
                t.b(t.v(t.f("zscore-currentPrice", c, p, 0)));
                t.b("</div>\r");
                t.b("\n" + i);
                t.b("       <div class=\"zscore-buyNowPrice\">");
                t.b(t.v(t.f("zscore-buyNowPrice", c, p, 0)));
                t.b("</div>\r");
                t.b("\n" + i);
                t.b("       <div class=\"zscore-data-bids\">");
                t.b(t.v(t.f("zscore-data-bids", c, p, 0)));
                t.b("</div>\r");
                t.b("\n" + i);
                t.b("   </div>\r");
                t.b("\n" + i);
                t.b("</div>\r");
                t.b("\n" + i);
            });
            c.pop();
        }
        return t.fl();
    },
    partials: {},
    subs: {}
});
sayrer commented 3 years ago

This looks like a non UTF-8 shell in Windows 10. Closing, but re-open if this is incorrect.