#49 – How to prevent HTML to be stripped

Posted in ‘weeblrAMP’
This is a public ticket. Everybody will be able to see its contents. Only enter usernames, passwords or any other sensitive information in the Private information field.
Thursday, 01 February 2018 13:42 UTC

I'm trying to replace the current menu item by using a custom template.
But how can i prevent that this code underneath (checkbox and label) is stripped from the html?
<input id="toggle-menu" type="checkbox"/>
        <label class="toggle-menu-header" for="toggle-menu">
            <?php if ( $this->hasDisplayData( 'navigation_menu_button_text' ) ) : ?>
            <?php echo $this->getEscaped( 'navigation_menu_button_text' ); ?>
            <?php endif; ?>
            <i class="fa fa-bars"></i>

Sivard Donkers
Thursday, 01 February 2018 14:10 UTC

First off, can I ask what you are trying to achieve? Using a check box to toggle a menu is not very efficient with AMP, as forms need to be handled very differently in AMP so you have to be aware of that if you write your own.

Second, and for that very reason, standard forms are removed automatically as they make AMP pages invalid. To prevent that, and build your own forms, you have to wrap the entire form with a special weeblrAMP function call. This will tell weeblrAMP that this part of the page should be validated and converted using a form-compatible specification. It goes like this:

$content = <<<<<AMP
Your content with form and input fields

$content = WeeblrampFactory::getThe( 'weeblramp.content.protector' )
			                           $content ,
				                           WeeblrampFactory::getA(  // amp converter, with forms
						                           'amp_config' => WeeblrampFactory::getA( 'weeblramp.config.ampform' )
echo $content;

This will cause whatever your content is to be replaced by a token. Later on, when the page is rendered and converted to AMP, that token will be replaced by your initial content transformed into AMP code but using the "weeblramp.config.ampform" configuration that allows forms and input elements.

Again, I'm not sure using an "input" is the way to go here.

Thursday, 01 February 2018 15:24 UTC
Hi there,

I have reviewed the matter in more details, and now that AMP allows some of the inputs without generating a validation error, I have updated the specification file in weeblrAMP to allow those inputs.
That should make your life easier if you still need to use a checkbox here. The updated version is available from the development versions download area.

In case you need to include an entire form, you still need to wrap it using the call I mentioned earlier. However this was indeed tedious, so this new dev version also has a new API method that you can use instead (the old syntax is fine, it'ts just more cumbersome):

$content = <<<AMP
Your content with form and input fields

echo  Weeblramp_Api::wrapForm($content);

Friday, 02 February 2018 11:19 UTC
I want to change the styling of the menu button when the sidebar is open and change it back when the menu is closed.
I can't see how to do this in styling since the button is outside the amp-sidebar.

See for an example http://spotler.test3.bluemammoth.nl/amp/

Friday, 02 February 2018 13:39 UTC

I think you can use

section[expanded] wbamp-control {...}

for that purpose.

Saturday, 17 February 2018 05:34 UTC
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.