Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates script[type=text/plain] are removed if "id" attribute is added #4277

Closed
grapheon opened this issue Feb 11, 2020 · 2 comments
Closed
Labels
Support Help with setup, implementation, or "How do I?" questions.

Comments

@grapheon
Copy link

grapheon commented Feb 11, 2020

Bug Description

If add "id" attribute to template like <script id="my-template" type="text/plain" template="amp-mustache">...</template> to refer to it, for example from <amp-list>, the plugin will completely remove this template from the resulting code.

Expected Behaviour

Provide "id" attribute support for templates like <script id="my-template" type="text/plain" template="amp-mustache">...</template>.

Steps to reproduce

  1. Add code to AMP page:
<script type="text/plain" template="amp-mustache">
    <h2>Plain template</h2>
</script>
<script id="my-template" type="text/plain" template="amp-mustache">
    <h2>Referenced template</h2>
</script>
  1. View the resulting source code for an AMP page.
  2. Make sure the <script id="my-template" type="text/plain" template="amp-mustache">...</template> is missing.

Please also see issue #26676.

Additional context

  • WordPress version: 5.3.2
  • Plugin version: 1.4.2
  • AMP plugin template mode: Website; Standard; Serve all templates as AMP regardless of what is being queried.
  • PHP version: 7.3.11

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

@westonruter
Copy link
Member

@spasibych Your markup seems malformed:

<script type="text/plain" template="amp-mustache">
    <h2>Plain template</h2>
</template>
<script id="my-template" type="text/plain" template="amp-mustache">
    <h2>Referenced template</h2>
</template>

Should it not rather be:

<script type="text/plain" template="amp-mustache">
    <h2>Plain template</h2>
</script>
<script id="my-template" type="text/plain" template="amp-mustache">
    <h2>Referenced template</h2>
</script>

Note </script> rather than </template> should be used.

@grapheon
Copy link
Author

@westonruter is my mistake, i'm sorry.

Now I tried it and it works. Maybe something from "blacklisted_value_regex" got in the way earlier.

@westonruter westonruter added the Support Help with setup, implementation, or "How do I?" questions. label Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

2 participants