harttle / liquidjs

A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
https://liquidjs.com
MIT License
1.52k stars 238 forks source link

Several filters missing from filters/overview.html page #482

Closed pdehaan closed 2 years ago

pdehaan commented 2 years ago

Re: https://liquidjs.com/filters/overview.html

I noticed that the json filter wasn't listed in the table, so I wrote a quick little scraper that verified the sidebar links vs the table values.

TLDR: The at_least, at_most, compact, default, json, and size filters aren't listed in the table.

// From the DevTools console

// $$("table > tbody td+td").flatMap(td => td.innerText.split(", ")).sort()
const table43 = ['abs', 'append', 'capitalize', 'ceil', 'concat', 'date', 'divided_by', 'downcase', 'escape', 'escape_once', 'first', 'floor', 'join', 'last', 'lstrip', 'map', 'minus', 'modulo', 'newline_to_br', 'plus', 'prepend', 'remove', 'remove_first', 'replace', 'replace_first', 'reverse', 'round', 'rstrip', 'slice', 'sort', 'sort_natural', 'split', 'strip', 'strip_html', 'strip_newlines', 'times', 'truncate', 'truncatewords', 'uniq', 'upcase', 'url_decode', 'url_encode', 'where']

// $$(".sidebar-link+.sidebar-link").map(a => a.innerText)
const sidebar49 = ['abs', 'append', 'at_least', 'at_most', 'capitalize', 'ceil', 'compact', 'concat', 'date', 'default', 'divided_by', 'downcase', 'escape', 'escape_once', 'first', 'floor', 'join', 'json', 'last', 'lstrip', 'map', 'minus', 'modulo', 'newline_to_br', 'plus', 'prepend', 'remove', 'remove_first', 'replace', 'replace_first', 'reverse', 'round', 'rstrip', 'size', 'slice', 'sort', 'sort_natural', 'split', 'strip', 'strip_html', 'strip_newlines', 'times', 'truncate', 'truncatewords', 'uniq', 'upcase', 'url_decode', 'url_encode', 'where']

const missing = sidebar49.filter(filter => !table43.includes(filter));
console.log({missing}); // ['at_least', 'at_most', 'compact', 'default', 'json', 'size']
pdehaan commented 2 years ago

The https://liquidjs.com/tags/overview.html page has 17 items in the sidebar and 17 in the table, but not the same 17 items.

$$(".sidebar-link + .sidebar-link").map(a => a.innerText);
// (17) ['assign', 'capture', 'case', 'comment', 'cycle', 'decrement', 'echo', 'for', 'if', 'include', 'increment', 'layout', 'liquid', 'raw', 'render', 'tablerow', 'unless']

$$("table > tbody td+td+td").flatMap(tag => tag.innerText.split(", ")).sort();
// (17) ['assign', 'case', 'comment', 'cycle', 'decrement', 'else', 'elsif', 'for', 'if', 'include', 'increment', 'layout', 'raw', 'render', 'tablerow', 'unless', 'when']
TAG SIDEBAR TABLE NOTES
assign :heavy_check_mark: :heavy_check_mark:
capture :heavy_check_mark: :x:
case :heavy_check_mark: :heavy_check_mark:
comment :heavy_check_mark: :heavy_check_mark:
cycle :heavy_check_mark: :heavy_check_mark:
decrement :heavy_check_mark: :heavy_check_mark:
echo :heavy_check_mark: :x:
else :x: :heavy_check_mark: See if page
elsif :x: :heavy_check_mark: See if page
for :heavy_check_mark: :heavy_check_mark:
if :heavy_check_mark: :heavy_check_mark:
include :heavy_check_mark: :heavy_check_mark:
increment :heavy_check_mark: :heavy_check_mark:
layout :heavy_check_mark: :heavy_check_mark:
liquid :heavy_check_mark: :x:
raw :heavy_check_mark: :heavy_check_mark:
render :heavy_check_mark: :heavy_check_mark:
tablerow :heavy_check_mark: :heavy_check_mark:
unless :heavy_check_mark: :heavy_check_mark:
when :x: :heavy_check_mark: See case page

// $$(".sidebar-link + .sidebar-link").map(a => a.innerText); // 17 tags
const sidebarTags = ['assign', 'capture', 'case', 'comment', 'cycle', 'decrement', 'echo', 'for', 'if', 'include', 'increment', 'layout', 'liquid', 'raw', 'render', 'tablerow', 'unless']

// $$("table > tbody td+td+td").flatMap(tag => tag.innerText.split(", ")).sort(); // 17 tags
const tableTags = ['assign', 'case', 'comment', 'cycle', 'decrement', 'else', 'elsif', 'for', 'if', 'include', 'increment', 'layout', 'raw', 'render', 'tablerow', 'unless', 'when']

const allTags = new Set([...sidebarTags, ...tableTags].sort()); // 20 tags

for (const tag of allTags) {
  console.log(`\`${tag}\` | ${boolEmoji(sidebarTags.includes(tag))} | ${boolEmoji(tableTags.includes(tag))}`);
}

function boolEmoji(value) {
  return !!value ? ":heavy_check_mark:" : ":x:";
}