Skip to content

Error: Unrecognized Tag

Michael Rawlings edited this page Apr 4, 2017 · 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).

If you are using an HTML custom element in your Marko template, you will need to register the custom element. Simply 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:

<my-custom-element name="Frank" />

src/html-elements.json:

{
  "<my-custom-element>": {}
}

With that change in place, the Marko compiler will not complain that the <my-custom-element> tag is unrecognized.

Clone this wiki locally