{%- if page.difficulty < 6 and page.difficulty > 0 -%} {%- comment -%} note: these characters are invalid unicode. they will only render properly on the webpage using the bundled "stars" font. {%- endcomment -%} {%- assign empty_star ="" -%} {%- assign full_star = "" -%} {%- assign half_star = "" -%} {%- comment -%} build a string of empty stars {%- endcomment -%} {%- assign difficulty = "" -%} {%- for i in (1..5) -%} {%- assign difficulty = difficulty | append: empty_star -%} {%- endfor -%} {%- comment -%} replace the first page.difficulty stars will filled stars {%- endcomment -%} {%- assign page_difficulty_rounded = page.difficulty | floor -%} {%- for i in (1..page_difficulty_rounded) -%} {%- assign difficulty = difficulty | replace_first: empty_star, full_star -%} {%- endfor -%} {%- if page.difficulty != page_difficulty_rounded -%} {%- comment -%} difficulty ends in .5 (or .1, or .9, or whatever) {%- endcomment -%} {%- assign difficulty = difficulty | replace_first: empty_star, half_star -%} {%- endif -%} {{ difficulty }} {%- endif -%}