janl / mustache.js

Minimal templating with {{mustaches}} in JavaScript

Home Page:https://mustache.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to prevent mustache from encoding the url value?

fzn0x opened this issue · comments

commented

How to prevent mustache from encoding the url value?

const stringDoc = Mustache.render("This is your {{ endpoint }}", {
  endpoint: "https://loli.dev",
});
console.log(stringDoc); // https://loli.dev

Expected value

This is your https://loli.dev

commented

Decoding the result solve my issue, if it's still the part of the mustache issue, you can reopen it.

stringDoc = stringDoc.replace(REG_HEX, function (match, group) {
  var num = parseInt(group, 16); //=> 39
  return String.fromCharCode(num); //=> '
});

console.log(stringDoc);

Happy hacking!

This is your {{{ endpoint }}}

Was not an option to avoid HTML escaping completely?

commented
This is your {{{ endpoint }}}

Was not an option to avoid HTML escaping completely?

Wow, you are right haha. I missed that part in the docs! 😄

commented

Thank you!