Skip to content

Missing helpers after latest update #1553

@paulfalgout

Description

@paulfalgout

Before filing issues, please check the following points first:

This will probably help you to get a solution faster.
For bugs, it would be great to have a PR with a failing test-case.

I can try and find a way to reproduce this, but to get it started in case it's somehow obvious. In 4.1.2 everything with the below helpers worked fine. In 4.2.0 I get "Missing helper: "far""... but it only seems to error when I'm instrumenting the code with istanbul.

However there are no other changes npm i [email protected] fixes the issue and @4.2.0 causes it again.

import _ from 'underscore';
import Handlebars from 'handlebars/runtime';
import { findIconDefinition, icon, config } from '@fortawesome/fontawesome-svg-core';
import '@fortawesome/fontawesome-svg-core/styles.css';

config.autoAddCss = false;
config.replacementClass = 'svg-inline--fa icon';

function faHelper(prefix, iconName, { hash = {} }) {
  const faDefinition = findIconDefinition({ prefix, iconName });
  const faIcon = icon(faDefinition, hash);

  if (!faIcon || !faIcon.html) {
    throw new Error(`${ prefix }:${ iconName } fontawesome icon not loaded`);
  }
  return new Handlebars.SafeString(faIcon.html);
}

// {{far "acorn"}} -> <svg ...>
Handlebars.registerHelper({
  far: _.partial(faHelper, 'far'),
  fas: _.partial(faHelper, 'fas'),
  fal: _.partial(faHelper, 'fal'),
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions