Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Block Variable Regex is too greedy #9

Open
mwunsch opened this issue Sep 20, 2010 · 0 comments
Open

Block Variable Regex is too greedy #9

mwunsch opened this issue Sep 20, 2010 · 0 comments
Labels

Comments

@mwunsch
Copy link
Owner

mwunsch commented Sep 20, 2010

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}">&larr; {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} &rarr;</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}">&larr; {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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant