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

📖 Mention that amp-state can contain a constant #37479

Merged
merged 4 commits into from
Jan 26, 2022
Merged

Conversation

morsssss
Copy link
Contributor

Add an example showing that it can be initialized to a constant, not just an object. (This is something I was never sure about when I first started using AMP.)

Note - I wasn't able to get the import to work on my local machine, so I tested this with an outdated version of the docs. It might be worth verifying this on a fully working build!

Add an example showing that it can be initialized to a constant, not just an object. (This is something I was never sure about when I first started using AMP.)
<amp-state id="singleton">
<script type="application/json">
{
'I am a string'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not valid JSON, is that intended?

This would work afaik:

<script type="application/json">
  'I am a string'
</script>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I tested out something that looks exactly like what you did. Then, when I edited the docs, I added the useless curly brackets.

@sebastianbenz sebastianbenz merged commit 0e67027 into main Jan 26, 2022
rileyajones pushed a commit to rileyajones/amphtml that referenced this pull request Jan 26, 2022
* Mention that amp-state can contain a constant

Add an example showing that it can be initialized to a constant, not just an object. (This is something I was never sure about when I first started using AMP.)

* Is prettify complaining because my line's >= 80 characters?

* Trying still to make prettier happy. So embarrassing.

* Remove spurious curly braces
samouri pushed a commit to samouri/amphtml that referenced this pull request Feb 2, 2022
* Mention that amp-state can contain a constant

Add an example showing that it can be initialized to a constant, not just an object. (This is something I was never sure about when I first started using AMP.)

* Is prettify complaining because my line's >= 80 characters?

* Trying still to make prettier happy. So embarrassing.

* Remove spurious curly braces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants