Refactor liquid templates

This commit is contained in:
Andrea Cardaci 2018-09-15 14:00:16 +02:00
parent 67b27cc0d9
commit 45b926300f
2 changed files with 14 additions and 19 deletions

View File

@ -1,8 +1,8 @@
<ul class="function-list"> <ul class="function-list">
{% for function in site.data.functions %} {% for function_pair in site.data.functions %}
{% assign function_name = function[0] %} {% assign function_id = function_pair[0] %}
{% if include.bin.functions[function_name] %} {% assign function = function_pair[1] %}
<li><a href="{{ include.bin.url }}#{{ function_name }}">{{ site.data.functions[function_name].label }}</a></li> {% unless include.bin.functions[function_id] %}{% continue %}{% endunless %}
{% endif %} <li><a href="{{ include.bin.url }}#{{ function_id }}">{{ function.label }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -10,27 +10,24 @@ layout: common
{{ page.description | markdownify }} {{ page.description | markdownify }}
{% for function in site.data.functions %} {% for function_pair in site.data.functions %}
{% assign function_name = function[0] %} {% assign function_id = function_pair[0] %}
{% assign examples = page.functions[function_name] %} {% assign function = function_pair[1] %}
{% if examples %} {% assign examples = page.functions[function_id] %}
{% unless examples %}{% continue %}{% endunless %}
<h2 id="{{ function_name }}" class="function-name"> <h2 id="{{ function_id }}" class="function-name">{{- function.label -}}</h2>
{{- site.data.functions[function_name].label -}} {{ function.description | markdownify }}
</h2>
{{ site.data.functions[function_name].description | markdownify }}
<ul class="examples"> <ul class="examples">
{% for example in examples %} {% for example in examples %}
{% capture code %} {% capture code %}
{%- if function_name == 'suid-enabled' or function_name == 'suid-limited' %} {%- if function_id == 'suid-enabled' or function_id == 'suid-limited' %}
cp $(which {{ bin_name }}) . cp $(which {{ bin_name }}) .
sudo sh -c 'chown 0 ./{{ bin_name }}; chmod +s ./{{ bin_name }}' sudo sh -c 'chown 0 ./{{ bin_name }}; chmod +s ./{{ bin_name }}'
{% endif %} {% endif %}
{%- if function_name == 'capabilities-enabled' %} {%- if function_id == 'capabilities-enabled' %}
cp $(which {{ bin_name }}) . cp $(which {{ bin_name }}) .
sudo setcap cap_setuid+ep {{ bin_name }} sudo setcap cap_setuid+ep {{ bin_name }}
{% endif %} {% endif %}
@ -43,8 +40,6 @@ sudo setcap cap_setuid+ep {{ bin_name }}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %}
{% endfor %} {% endfor %}