Skip to content

Error: Unrecognized Tag

Dylan Piercey edited this page Dec 3, 2018 · 11 revisions

Not expecting a tag? If you're writing text at the root of a template, remember, Marko starts in concise mode and any text not prefixed with -- will be parsed as a tag declaration.

When Marko encounters an unrecognized tag at compile-time it will throw an error by default. For example:

[template.marko:0:1] Unrecognized tag: invalid-tag

Marko will only discover tags from packages that are listed as dependencies or devDependencies in your package.json file. If the tag name looks correct, please make sure you have the package installed and listed.

While throwing on unrecognized tags allows Marko to catch potential problems as early as possible, it does require that Marko be aware of all of the possible tag names (including tag names for standard HTML elements, Marko UI components and custom HTML elements).

Web Components / AMP Components

For tags you wish to explicitly pass through as is, such as web components, you can provide Marko with a hint via an html-elements.json file. To register the custom element create a html-elements.json in the same directory or a higher up directory and register the tag as shown below.

src/components/hello/index.marko:

<amp-app-banner layout="nodisplay" id="demo-app-banner-2134">

src/html-elements.json:

{
  "<amp-app-banner>": {}
}

With that change in place, the Marko compiler will not complain that the <amp-app-banner> tag is unrecognized and instead output the tag as if it was a regular html tag.

Clone this wiki locally