Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug in token parsing loop #5

Merged
merged 6 commits into from
Jul 5, 2011

Conversation

warezthebeef
Copy link
Contributor

When parsing a template such as

{% if test %}{{ test | size }}{% else %}0{% endif %}

LiquidBlock.php:46 while ($token = array_shift($tokens)) loop was failing because $token = array_shift($tokens) evaluates as 0 on the second to last token and causes the while loop to end prematurely. Modified to evaluate the tokens array using count($tokens) and moved the $token variable assignment inside the while loop.

@warezthebeef
Copy link
Contributor Author

I've updated this pull request to include some more changes, first the include functionality has been modified to match current Ruby liquid as outlined in file_system.rb. Basically this means the extension is .liquid (rather than .tpl) and all partial files must be prefixed with an underscore.

file_system = Liquid::LocalFileSystem.new("/some/path")

file_system.full_path("mypartial")       # => "/some/path/_mypartial.liquid"
file_system.full_path("dir/mypartial")   # => "/some/path/dir/_mypartial.liquid"

WARNING: While this now matches Ruby liquid it will break functionality for people who are already using .tpl partials

Next I've modified the if statement to support and/or logic as well as elsif blocks. So statements such as the following are now valid

{% if test1 and test2 %}
if works
{% elsif test1 or test2 %}
elsif works
{% else %}
else works
{% endif %}

harrydeluxe pushed a commit that referenced this pull request Jul 5, 2011
Fixed bug in token parsing loop
@harrydeluxe harrydeluxe merged commit 3bf3de1 into harrydeluxe:master Jul 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants