Closed tinovyatkin closed 4 years ago
You need to tell Marko what the valid attributes for your tag are. Either specify the exact attributes you expect or use @*: "string"
(also, use lower case 's' for 'string') to just accepting anything.
So either everything...
{
"<amp-analytics>": {
"@*": "string"
}
}
or be specific about ALL attributes. In your last example, you are only defining what data-credentials
is, but not config
.
{
"<amp-analytics>": {
"@config": "string",
"@data-credentials": "string"
}
}
@jasonmacdonald neither solution work, unfortunately, resulting in the same error.
@tinovyatkin If you can provide a simple example of your component, I can try and dig deeper to see what's going on.
@jasonmacdonald There is no component, as I write above, I have a Marko template that should output <amp-analytics>
as is, i.e. simple example is:
$ const { tagManagerAMP } = input;
<amp-analytics else-if(out.global.amp && tagManagerAMP)
config="https://www.googletagmanager.com/amp.json?id=${tagManagerAMP}>m.url=SOURCE_URL"
data-credentials="include">
</amp-analytics>
How to make this template compiling?
Ohhhhh, I see. The <amp-analytics>
isn't a Marko component. Sorry, I missed that bit. Still, I just tried to add a tag like that to a test project and it worked fine using...
{
"<amp-analytics>": {
"@config": "string",
"@data-credentials": "string"
}
}
The tag was retained, as is, in the output rendered by the browser. So, there might be something else going on, it does work.
Here's a screen grab from the chrome dev-tools
Hi @tinovyatkin -- this is similar to the failing test case I showed here: https://github.com/marko-js/marko/pull/918
As a workaround, try adding an entry to your top level marko.json
:
"<amp-analytics>": {"html": true}
@yomed Thank you, top level marko.json
did the magic! Is this behavior documented anywhere?
Nice! Unfortunately, I don't think it's currently documented. @mlrawlings dug up this workaround for me when I made that PR.
This is now sorta documented at https://markojs.com/docs/marko-json/#options, but without much explanation. This issue seems like a good candidate for a Troubleshooting section.
"<amp-analytics>": {"html": true}
is the correct work around and is now documented 😄.
https://markojs.com/docs/marko-json/
Bug Report
Marko Version: 4.9.0
Details
Expected Behavior
I'm trying to include AMP custom tag into my Marko template to be rendered 'as-is', ie, as custom HTML element.
and
html-elements.json
to make Marko recognizing tag:However, Marko throws with following error:
I've tried to change
html-elements.json
like this, but it doesn't helps:The above code compiles fine without
data-*
attribute.Is there any workaround?