Last active
March 4, 2021 14:57
-
-
Save kyktommy/746e8c6a2e15b41dc947fb83cbd3b287 to your computer and use it in GitHub Desktop.
ejs + format str
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ejs = require("ejs"); | |
const IntlMessageFormat = require("intl-messageformat").default; | |
const t = (str, obj) => new IntlMessageFormat(str).format(obj); | |
const data = { t: t, title: "hello world {name}" }; | |
const html = ejs.render("<%- t(title, {name: 'bot'}) %>", data); | |
console.log(html); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ejs = require("ejs"); | |
const t = require("util").format; | |
const data = { t, title: "hello world %s" }; | |
const html = ejs.render("<%- t(title, 'bot') %>", data); | |
console.log(html); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment