[Bug]: Liquid Exception: divided by 0
typo3ua opened this issue · 0 comments
Operating System
Ubuntu 20.04.6 LTS
Ruby Version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
Jekyll Version
from 4.1.1 to 4.3.2
GitHub Pages Version
Expected Behavior
I did it on my local PC
{{ 5 | divided_by: 6.0 }}
Output: 0.833333
{{ 24 | modulo: 8 }}
Output: 4
{{ 21 | divided_by: 7 }}
Output: 3
{{ 24 | modulo: 7 }}
Output: 3
But if these variables are page specific (declared in YML frontmatter) they fail.
{% assign x = 5 %}
{% assign y = 6.0 %}
{{ x | divided_by: y }}
...or...
{{ page.x | divided_by: page.y }}
the same with the `modulo`
{{ page.x | modulo: page.y }}
Causes the following error:
Liquid Exception: Liquid error (line 7): divided by 0 in /home/local/dev/jekyll/bar/main/_layouts/foo.html
Error: Liquid error (line 7): divided by 0
Error: Run jekyll build --trace for more information.
Current Behavior
But if these variables are page specific (declared in YML frontmatter) they fail.
{{ page.x | divided_by: page.y }}
liquid-4.0.4/lib/liquid/standardfilters.rb:376:in rescue in divided_by: Liquid error (line 7): divided by 0 (Liquid::ZeroDivisionError)
Relevant log output
I found the issue here... https://github.com/jekyll/jekyll/issues/3813
@parkr, wrote:
> The bytesize error was fixed in https://github.com/jekyll/jekyll/pull/3811. Can you use the latest master and try again?
... but I still have this issue
Code Sample
I tried different variations of codes but results the same...
---
layout: default
title: Test page
sur: 250
pi: 250000
pi_i:
---
{{ page.pi | divided_by: page.sur }}
{{ page.pi | divided_by: page.sur | times: site.cou | ceil }}
{{ page.pi | times: site.cou | ceil | divided_by: page.sur }}
{%- assign pi = page.pi_i | default: page.pi -%}
{%- assign sur = page.sur -%}
{%- assign pi = page.pi_i | default: page.pi | strip -%}
{%- assign sur = page.sur | strip -%}
#sur = {{ sur }} > output = 250
#pi = {{ sur }} > output = 250000
{{ pi | divided_by: sur }}
{{ pi | divided_by: sur | times: site.cou | ceil }}
{{ pi | times: site.cou | ceil | divided_by: sur }}
I can to reproduce and have reproduced this problem on this Jekyll theme...
https://github.com/jekyll/minima
I cloned the repo on a local machine after running the command ...
dev/jekyll/minima$ bundle install
and
dev/jekyll/minima$ bundle exec jekyll serve
then go to the post
https://github.com/jekyll/minima/blob/master/_posts/2016-05-20-this-post-demonstrates-post-content-styles.md
added new variables
---
layout: post
title: "This post demonstrates post content styles"
ps:
p: 250000
s: 250
categories: junk
author:
- Bart Simpson
- Nelson Mandela Muntz
meta: "Springfield"
---
then go to the layout
https://github.com/jekyll/minima/blob/master/_layouts/post.html
added this code...
{%- assign s = page.s | strip -%}
{%- assign p = page.ps | default: page.p | strip -%}
#01 p = -{{ p }}- <br>
#02 s = -{{ s }}- <br>
#03 price for m == {{ p | divided_by: s | ceil }} <br>
#04 price for m == {{ p | divided_by: s }} <br>
#031 price for m == {{ page.p | divided_by: page.s | ceil }} <br>
#042 price for m == {{ page.p | divided_by: page.s }} <br>
and i get error
Regenerating: 1 file(s) changed at 2023-12-14 00:16:29
_layouts/post.html
Jekyll Feed: Generating feed for posts
Liquid Exception: Liquid error (line 7): divided by 0 in /home/local/dev/jekyll/minima/_layouts/post.html
Error: Liquid error (line 7): divided by 0
Error: Run jekyll build --trace for more information.