Skip to content
Snippets Groups Projects
Commit df98f32f authored by Kevin Lin's avatar Kevin Lin
Browse files

_includes: Remove eval.liquid, split.liquid dependencies

parent 86aa5e5e
No related branches found
No related tags found
No related merge requests found
{% capture eval_workspace %}
{% comment %}
Evaluate Liquid tags stored in plaintext.
Supports:
`link` tag for site.pages. Does not raise errors on invalid links.
Parameters:
`content` (string): String containing Liquid tags.
{% endcomment %}
{% capture tags %}{{ "{%|" }}%}{% endcapture %}
{% assign tags = tags | split: "|" %}
{% assign join = "|" %}
{% capture parts %}{% include split.liquid content=include.content queries=tags join=join %}{% endcapture %}
{% assign parts = parts | split: join %}
{% assign result = "" %}
{% for part in parts %}
{% assign subparts = part | split: " " %}
{% assign rest = subparts | slice: 1, subparts.size | join: " " %}
{% case subparts[0] %}
{% when "link" %}
{% comment %}
Jekyll 4.0 supports Liquefied link tags: https://github.com/jekyll/jekyll/pull/6269
{% endcomment %}
{% for page in site.pages %}
{% if page.path == rest %}
{% assign link = page.url | relative_url %}
{% assign result = result | append: link %}
{% endif %}
{% endfor %}
{% else %}
{% assign result = result | append: part %}
{% endcase %}
{% endfor %}
{% endcapture %}{% assign eval_workspace = '' %}{{ result }}
{% capture split_workspace %}
{% comment %}
Split the string on all of the delimiters and join the result.
Parameters:
`content` (string): String to split.
`delimiters` (array of strings): Boundary strings defining what to split.
`join` (string): Join the resulting parts on this string.
{% endcomment %}
{% assign queries = include.queries | default: empty %}
{% assign join = include.join | default: "|" %}
{% if queries.size == 0 %}
{% assign result = include.content %}
{% else %}
{% assign result = include.content | split: queries[0] | join: join %}
{% assign rest = queries | slice: 1, queries.size %}
{% for query in rest %}
{% assign temp = result | split: join %}
{% assign result = "" %}
{% for part in temp %}
{% assign split = part | split: query %}
{% for subpart in split %}
{% comment %}
Suppress repeated delimiters (empty strings).
{% endcomment %}
{% if subpart != "" %}
{% assign result = result | append: join | append: subpart %}
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
{% endcapture %}{% assign split_workspace = '' %}{{ result }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment