Skip to content

Commit

Permalink
✨ Allow <amp-render> within story pages and story page attachments (#…
Browse files Browse the repository at this point in the history
…35497)

* Allow <amp-render> as a valid child component of story pages and story page attachments

* Add newline to end of the .out test file

* Update copyright date in extensions/amp-story/1.0/test/validator-amp-story-amp-render.html

Co-authored-by: Gabriel Majoulet <gmajoulet@google.com>

* Move the placeholder and fallback divs within the amp-render element

* Update mustache templates

* Remove unnecessary template attribute

* Add newline at end of .out file

* Add comments to test file that point to the amp-render usage

* Add the TEMPLATE tag as a valid descendant of page attachments, and then move the template element in validator-amp-story-amp-render.html inside of the amp-story-page-attachment element

* Update the validator output file

* Add newline to end of .out file

Co-authored-by: Gabriel Majoulet <gmajoulet@google.com>
  • Loading branch information
coreymasanto and gmajoulet committed Aug 10, 2021
1 parent 7741dcc commit 3081038
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 0 deletions.
97 changes: 97 additions & 0 deletions extensions/amp-story/1.0/test/validator-amp-story-amp-render.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!--
Copyright 2021 The AMP HTML Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the license.
-->
<!--
Test Description:
Tests for the amp-render functionality inside amp-story.
-->
<!DOCTYPE html>
<html amp lang="en">
<head>
<meta charset="utf-8" />
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-story"
src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>
<script async custom-element="amp-render"
src="https://cdn.ampproject.org/v0/amp-render-1.0.js"></script>
<script async custom-template="amp-mustache"
src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<script async custom-element="amp-bind"
src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<title>amp-render</title>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/>
<link rel="canonical" href="index.html" />
<style amp-boilerplate>
body{
-webkit-animation:-amp-start 8s steps(1, end) 0s 1 normal both;
-moz-animation:-amp-start 8s steps(1, end) 0s 1 normal both;
-ms-animation:-amp-start 8s steps(1, end) 0s 1 normal both;
animation:-amp-start 8s steps(1, end) 0s 1 normal both
}
@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
</style>
<noscript>
<style amp-boilerplate>
body{
-webkit-animation:none;
-moz-animation:none;
-ms-animation:none;
animation:none
}
</style>
</noscript>
</head>

<body>
<amp-story standalone title="My Story" publisher="Me"
publisher-logo-src="http://me.com/logo.png"
poster-portrait-src="http://me.com/poster.jpg">
<amp-story-page id="page-rendering">
<amp-story-grid-layer template="vertical">
<!-- Valid: amp-render within amp-story-page -->
<amp-render
layout="fixed-height"
height="100"
src="/examples/images.json"
binding="no">
<template id="my-page-template" type="amp-mustache">
<div>{{#images}}<b><a href="{{urls.picsum}}">{{author}}</a></b>{{/images}}</div>
</template>
<div placeholder>Loading ...</div>
<div fallback>Failed to load data.</div>
</amp-render>
</amp-story-grid-layer>
</amp-story-page>

<amp-story-page id="attachment-rendering">
<amp-story-page-attachment layout="nodisplay">
<h1>Page Attachment</h1>
<!-- Valid: amp-render within amp-story-page-attachment -->
<amp-render
layout="fixed-height"
height="100"
src="/examples/images.json"
binding="no"
template="my-attachment-template">
</amp-render>
<template id="my-attachment-template" type="amp-mustache">
<div>{{#images}}<b><a href="{{urls.picsum}}">{{author}}</a></b>{{/images}}</div>
</template>
</amp-story-page-attachment>
</amp-story-page>
</amp-story>
</body>
</html>
98 changes: 98 additions & 0 deletions extensions/amp-story/1.0/test/validator-amp-story-amp-render.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
PASS
| <!--
| Copyright 2021 The AMP HTML Authors. All Rights Reserved.
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
| http://www.apache.org/licenses/LICENSE-2.0
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS-IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the license.
| -->
| <!--
| Test Description:
| Tests for the amp-render functionality inside amp-story.
| -->
| <!DOCTYPE html>
| <html amp lang="en">
| <head>
| <meta charset="utf-8" />
| <script async src="https://cdn.ampproject.org/v0.js"></script>
| <script async custom-element="amp-story"
| src="https://cdn.ampproject.org/v0/amp-story-1.0.js"></script>
| <script async custom-element="amp-render"
| src="https://cdn.ampproject.org/v0/amp-render-1.0.js"></script>
| <script async custom-template="amp-mustache"
| src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
| <script async custom-element="amp-bind"
| src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
| <title>amp-render</title>
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/>
| <link rel="canonical" href="index.html" />
| <style amp-boilerplate>
| body{
| -webkit-animation:-amp-start 8s steps(1, end) 0s 1 normal both;
| -moz-animation:-amp-start 8s steps(1, end) 0s 1 normal both;
| -ms-animation:-amp-start 8s steps(1, end) 0s 1 normal both;
| animation:-amp-start 8s steps(1, end) 0s 1 normal both
| }
| @-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
| @-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
| @-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
| @-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
| @keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}
| </style>
| <noscript>
| <style amp-boilerplate>
| body{
| -webkit-animation:none;
| -moz-animation:none;
| -ms-animation:none;
| animation:none
| }
| </style>
| </noscript>
| </head>
|
| <body>
| <amp-story standalone title="My Story" publisher="Me"
| publisher-logo-src="http://me.com/logo.png"
| poster-portrait-src="http://me.com/poster.jpg">
| <amp-story-page id="page-rendering">
| <amp-story-grid-layer template="vertical">
| <!-- Valid: amp-render within amp-story-page -->
| <amp-render
| layout="fixed-height"
| height="100"
| src="/examples/images.json"
| binding="no">
| <template id="my-page-template" type="amp-mustache">
| <div>{{#images}}<b><a href="{{urls.picsum}}">{{author}}</a></b>{{/images}}</div>
| </template>
| <div placeholder>Loading ...</div>
| <div fallback>Failed to load data.</div>
| </amp-render>
| </amp-story-grid-layer>
| </amp-story-page>
|
| <amp-story-page id="attachment-rendering">
| <amp-story-page-attachment layout="nodisplay">
| <h1>Page Attachment</h1>
| <!-- Valid: amp-render within amp-story-page-attachment -->
| <amp-render
| layout="fixed-height"
| height="100"
| src="/examples/images.json"
| binding="no"
| template="my-attachment-template">
| </amp-render>
| <template id="my-attachment-template" type="amp-mustache">
| <div>{{#images}}<b><a href="{{urls.picsum}}">{{author}}</a></b>{{/images}}</div>
| </template>
| </amp-story-page-attachment>
| </amp-story-page>
| </amp-story>
| </body>
| </html>
3 changes: 3 additions & 0 deletions extensions/amp-story/validator-amp-story.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ descendant_tag_list: {
tag: "AMP-LIST"
tag: "AMP-LIVE-LIST"
tag: "AMP-PIXEL"
tag: "AMP-RENDER"
tag: "AMP-STATE"
tag: "AMP-STORY-360"
tag: "AMP-STORY-AUTO-ANALYTICS"
Expand Down Expand Up @@ -1090,6 +1091,7 @@ descendant_tag_list {
tag: "AMP-POWR-PLAYER"
tag: "AMP-REACH-PLAYER"
tag: "AMP-REDDIT"
tag: "AMP-RENDER"
tag: "AMP-RIDDLE-QUIZ"
tag: "AMP-SOUNDCLOUD"
tag: "AMP-SPRINGBOARD-PLAYER"
Expand Down Expand Up @@ -1201,6 +1203,7 @@ descendant_tag_list {
tag: "TABLE"
tag: "TBODY"
tag: "TD"
tag: "TEMPLATE"
tag: "TEXT"
tag: "TEXTPATH"
tag: "TFOOT"
Expand Down

0 comments on commit 3081038

Please sign in to comment.