amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

amp-bind clashes with amp-render and Mustache templates

Open AaronMLB opened this issue 5 years ago • 3 comments

Description

When I include amp-bind (v0.1) in a page, it breaks the rendering of Mustache templates (v0.2) within amp-render (v1.0).

Specifically, I've found a simple amp-render containing a list is stripped of its opening and closing ul tags.

Reproduction Steps

AMPHTML:

            <amp-render src="/path/to/source/" layout="flex-item" credentials="include">
                <div placeholder>Hello!</div>
                <template type="amp-mustache">
                <ul>
                    <li><a on="tap:searchPanel" class="search-button">Search</a></li>
                    {{{menu}}}
                </ul>
                </template>
            </amp-render>

JSON:

{"menu":"
                    <li><a href=\"/account\/\">Account<\/a><\/li>
                    <li><a href=\"/account\/log-out\/\">Log out<\/a><\/li>"}

Rendered HTML

<amp-render src="/path/to/source/" layout="flex-item" credentials="include" template="user-menu" class="i-amphtml-element i-amphtml-layout-flex-item i-amphtml-layout-size-defined i-amphtml-built i-amphtml-layout" i-amphtml-layout="flex-item" aria-live="polite">
                <div placeholder="" class="amp-hidden">Hello!</div>
                <template type="amp-mustache" id="user-menu">
                <ul>
                    <li><a on="tap:searchPanel" class="search-button">Search</a></li>
                    {{{menu}}}
                </ul>
                </template>
            <div i-amphtml-rendered="true" loading="auto" aria-live="polite">
                    <li><a class="search-button" on="tap:searchPanel">Search</a></li>
                    
                    <li><a target="_top" href="/account/">Account</a></li>
                    <li><a target="_top" href="/account/log-out/">Log out</a></li>
                </div></amp-render>

Note within the <div i-amphtml-rendered="true" block, there are no <ul>s. If I remove the amp-bind component inclusion, or on any other page, it works perfectly.

AaronMLB avatar Jul 26 '21 19:07 AaronMLB

@AaronMLB thanks for reporting this issue. I am able to repro this and suspect it's a bug with template rendering. Need to investigate further and will update this issue when I have more.

dmanek avatar Jul 27 '21 17:07 dmanek

@AaronMLB thanks for reporting this issue. I am able to repro this and suspect it's a bug with template rendering. Need to investigate further and will update this issue when I have more.

Thanks @dmanek, will await.

AaronMLB avatar Jul 27 '21 17:07 AaronMLB

@AaronMLB figured out the issue. We were appending the innerHTML which would exclude the wrapper ul element. Fix in progress.

dmanek avatar Jul 29 '21 17:07 dmanek