thimble
thimble copied to clipboard
Block Variable Regex is too greedy
If you look at Redux's jump pagination implementation:
{block:Pagination}
<div id="navigation" {block:IfEnableJumpPagination}class="jump_pagination"{/block:IfEnableJumpPagination}>
{block:PreviousPage}<a href="{PreviousPage}">← {lang:Previous}</a>{/block:PreviousPage}
{block:IfEnableJumpPagination}
{block:JumpPagination length="5"}
{block:CurrentPage}
<span class="current_page">{PageNumber}</span>
{/block:CurrentPage}
{block:JumpPage}
<a class="jump_page" href="{URL}">{PageNumber}</a>
{/block:JumpPage}
{/block:JumpPagination}
{/block:IfEnableJumpPagination}
{block:NextPage}<a href="{NextPage}">{lang:Next page} →</a>{/block:NextPage}
</div>
{/block:Pagination}
There's an issue with the IfEnableJumpPagination
block: it will devour until the second {/block:IfEnableJumpPagination}
. That's not what we want, we want it to devour to the closest close block. I don't have enough regex magical ability to figure this one out though.
When I do something like this:
preg_match($this->block_pattern("If$block_name"), $doc, $matchy);
print_r($matchy);
$matchy[0]
looks like this:
{block:ifenablejumppagination}class="jump_pagination">
{block:PreviousPage}<a href="{PreviousPage}">← {lang:Previous}</a>{/block:PreviousPage}
{block:IfEnableJumpPagination}
{block:JumpPagination length="5"}
{block:CurrentPage}
<span class="current_page">{PageNumber}</span>
{/block:CurrentPage}
{block:JumpPage}
<a class="jump_page" href="{URL}">{PageNumber}</a>
{/block:JumpPage}
{/block:JumpPagination}
{/block:IfEnableJumpPagination}
How do fix?