Skip to content

Why am I getting (US$) and not ($) #86

@rochapablo

Description

@rochapablo

I'm using

"email-templates": "^2.5.4",
"handlebars": "^4.0.6",
"handlebars-intl": "^1.1.2",
"handlebars-layouts": "^3.1.4"

This is how I'm formatting

{{formatNumber price style="currency" currency="USD" locales="en-US"}}

And here's my js file

const handlebars = require('handlebars');
const handlebarsIntl = require('handlebars-intl');

handlebarsIntl.registerWith(handlebars);
handlebars.registerHelper(layouts(handlebars));
handlebars.registerPartial('layout', fs.readFileSync(`public/email-template/layout.hbs`, 'utf8'));

var intlData = {
  locales: 'en-US'
  // I also tried to follow this: https://formatjs.io/handlebars/ (Using Named Number Formats)
};

var newsletter = new EmailTemplate(path, {
  data: { intl: intlData }
});
handlebars.registerPartial('data', { intl: intlData });

newsletter.render({ params: { ... }, data: { intl: intlData } }, function (err, result) {
  if(err) { return reject(err); }
  return resolve(result.html);
});

Everything that I tried, or nothing happens or I got this error

ReferenceError: Could not find Intl object: formats.number.USD at intlGet (E:\www\unclehub\v0.2.2\api\node_modules\handlebars-intl\lib\helpers.js:96:23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions