Я использую форму AMP и не могу понять, как показать тот же html после отправки формы с некоторыми дополнительными элементами.
В целом моя разметка более сложная, но вот простой пример, который иллюстрирует, что мне нужно делать:
<form method="post" action-xhr="https://example.com/subscribe" target="_top" id="form1">
<ul>
<li>
<h2>Title 1</h2>
<input type="radio" value="1" name="answer" id="1" on="change:form1.submit">
<!-- Show this only on submit-success and there are used
some variables from amp-mustache -->
<div>Some Html {{Votes}}</div>
</li>
<li>
<h2>Title 2</h2>
<input type="radio" value="2" name="answer" id="2" on="change:form1.submit">
<!-- Show this only on submit-success and there are used
some variables from amp-mustache -->
<div>Some Html {{Votes}}</div>
</li>
...
</ul>
</form>
Я знаю, что могу использовать что-то вроде этого, но не хочу дублировать разметку (как я уже упоминал, это сложнее, чем приведенный пример):
<form method="post" action-xhr="https://example.com/subscribe" target="_top" id="form1">
<ul>
<li>
<h2>Title 1</h2>
<input type="radio" value="1" name="answer" id="1" on="change:form1.submit">
</li>
<li>
<h2>Title 2</h2>
<input type="radio" value="2" name="answer" id="2" on="change:form1.submit">
</li>
...
</ul>
<div submit-success>
<template type="amp-mustache">
<ul>
<li>
<h2>Title 1</h2>
<input type="radio" value="1" name="answer" id="1" class="relative" on="change:form1.submit">
<div>Some Html {{Votes}}</div>
</li>
<li>
<h2>Title 2</h2>
<input type="radio" value="2" name="answer" id="2" class="relative" on="change:form1.submit">
<div>Some Html {{Votes}}</div>
</li>
...
</ul>
</template>
</div>
</form>