statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Bug: Condition does not support `#` modifier value #1915

Closed mikemartin closed 6 years ago

mikemartin commented 6 years ago

Describe the bug {{ if link|starts_with:# }}data-scroll{{/if}} returns the error Parse error: syntax error, unexpected ':', when {{ link|starts_with:# }} returns true as expected.

Found a workaround by urlencoding the link and testing for %23: {{ if link|urlencode|starts_with:%23 }}data-scroll{{/if}}

Error log

Whoops, looks like something went wrong.
1/1
FatalThrowableError in Parser.php(1235) : eval()'d code line 7:
Parse error: syntax error, unexpected ':'
in Parser.php(1235) : eval()'d code line 7
at Parser->parsePhp(' <div class="d-flex w-100 flex-column text-center"> <div class="mt-2 mb-4"> <h2 class="display-1 display-1-giant text-white font-weight-normal mb-0">{{ number }}</h2> </div> <div class="bg-secondary py-1"> <h3 class="text-white"><?php if ('#experts'): ?><a href="{{ link }}" class="text-white" <?php if (true:#): ?>data-scroll<?php endif; ?>>{{ label }}</a><?php else: ?>{{ label }}<?php endif; ?></h3> </div> </div> ') in Parser.php line 772
at Parser->parseConditionals(' <div class="d-flex w-100 flex-column text-center"> <div class="mt-2 mb-4"> <h2 class="display-1 display-1-giant text-white font-weight-normal mb-0">{{ number }}</h2> </div> <div class="bg-secondary py-1"> <h3 class="text-white"><?php if ('#experts'): ?><a href="{{ link }}" class="text-white" <?php if (true:#): ?>data-scroll<?php endif; ?>>{{ label }}</a><?php else: ?>{{ label }}<?php endif; ?></h3> </div> </div> ', array('number' => '6', 'label' => 'Experts', 'link' => '#experts', 'key' => '0', 'index' => '1', 'zero_index' => '0', 'total_results' => '3', 'first' => true, 'last' => false, 'type' => 'stats', 'stats' => array(array('number' => '6', 'label' => 'Experts', 'link' => '#experts'), array('number' => '63', 'label' => 'Events', 'link' => '/events'), array('number' => '44', 'label' => 'Cities', 'link' => '#cities')), 'headline' => 'Who We Are', 'subtitle' => 'The API Academy team consists of industry experts who have been brought together by CA Technologies to provide expert consulting services for organizations that want to take their API programs to the next level.', 'page_content' => array(array('type' => 'stats', 'stats' => array(array('number' => '6', 'label' => 'Experts', 'link' => '#experts'), array('number' => '63', 'label' => 'Events', 'link' => '/events'), array('number' => '44', 'label' => 'Cities', 'link' => '#cities'))), array('type' => 'services', 'headline' => 'What We Do', 'subtitle' => 'We can help you understand the API economy, plan a program strategy, architect effective interfaces, build a secure, manageable API infrastructure and empower your developers to create truly valuable client apps.', 'button' => 'Let's Work Together'), array('type' => 'team', 'headline' => 'Meet Your Experts', 'team' => array('mike', 'matt', 'erik', 'ronnie', 'amy', 'mehdi')), array('type' => 'map', 'headline' => 'Where We've Been', 'subtitle' => 'API Academy is leads API discussions around the world. We can help you understand the API economy, plan a program strategy, architect effective interfaces.', 'button' => 'Meet us at an upcoming event')), 'footer_headline' => 'We're here to help', 'footer_subtitle' => 'Need help with your next project or just want to say hello?', 'footer_button' => array('label' => 'Contact Us', 'url' => '/about/contact'), 'is_hidden' => false, 'mount' => 'service', 'title' => 'About', 'template' => 'about/index', 'fieldset' => 'about', 'author' => 'apiacademy', 'content' => '<p>The API Academy team consists of industry experts who have been brought together by CA Technologies to provide expert consulting services for organizations that want to take their API programs to the next level.</p> <p><a href="mailto:apiacademy@ca.com">Contact us</a> to find out more about how we can help you understand the API economy, plan a program strategy, architect effective interfaces, build a secure, manageable API infrastructure and empower your developers to create truly valuable client apps.</p> <p>Email: <a href="mailto:apiacademy@ca.com">apiacademy@ca.com</a></p> ', 'id' => '91cf107a-8a75-4013-acef-328367713dfc', 'slug' => 'about', 'url' => '/about', 'uri' => '/about', 'url_path' => '/about', 'permalink' => '//localhost:3000/about', 'edit_url' => '/cp/pages/edit/about', 'published' => true, 'order' => '5', 'is_page' => true, 'last_modified' => '1525775693', 'content_raw' => 'The API Academy team consists of industry experts who have been brought together by CA Technologies to provide expert consulting services for organizations that want to take their API programs to the next level. <a href="mailto:apiacademy@ca.com">Contact us</a> to find out more about how we can help you understand the API economy, plan a program strategy, architect effective interfaces, build a secure, manageable API infrastructure and empower your developers to create truly valuable client apps.
jasonvarga commented 6 years ago

Kinda sorta a duplicate of #1113. Gonna close this one in favor of that.

Your workaround is a good one!