Skip to content

Commit

Permalink
feat(templates): add cacheString support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Andrade committed Sep 29, 2020
1 parent 4541235 commit f39d2c1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
10 changes: 5 additions & 5 deletions templates/template.css.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
font-style: normal;
font-weight: 400;
{% if formats.indexOf('eot')>-1 -%}
src: url("{{ fontPath }}{{ fontName }}.eot{% if hash %}?v={{ hash }}{% endif %}");
src: url("{{ fontPath }}{{ fontName }}.eot?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}");
{%- endif %}
{%- set eotIndex = formats.indexOf('eot') -%}
{%- set woff2Index = formats.indexOf('woff2') -%}
Expand All @@ -17,22 +17,22 @@
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woff2Index != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff2{% if hash %}?v={{ hash }}{% endif %}") format("woff2")
url("{{ fontPath }}{{ fontName }}.woff2?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("woff2")
{%- set nothing = formats.splice(woff2Index, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woffIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff{% if hash %}?v={{ hash }}{% endif %}") format("woff")
url("{{ fontPath }}{{ fontName }}.woff?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("woff")
{%- set nothing = formats.splice(woffIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if ttfIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.ttf{% if hash %}?v={{ hash }}{% endif %}") format("truetype")
url("{{ fontPath }}{{ fontName }}.ttf?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("truetype")
{%- set nothing = formats.splice(ttfIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if svgIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.svg{% if hash %}?v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
{%- endif %}
}

Expand Down
31 changes: 21 additions & 10 deletions templates/template.html.njk
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!doctype html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ fontName }}</title>
<style>
<style type="text/css">
body {
margin: 0;
padding:10px 20px;
Expand Down Expand Up @@ -43,6 +43,7 @@
display: inline-block;
line-height: 3em;
margin-left: 5px;
white-space: nowrap;
}
@font-face {
Expand All @@ -51,7 +52,7 @@
font-style: normal;
font-weight: 400;
{% if formats.indexOf('eot')>-1 -%}
src: url("{{ fontPath }}{{ fontName }}.eot{% if hash %}?v={{ hash }}{% endif %}");
src: url("{{ fontPath }}{{ fontName }}.eot?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}");
{%- endif %}
{%- set eotIndex = formats.indexOf('eot') -%}
{%- set woff2Index = formats.indexOf('woff2') -%}
Expand All @@ -64,22 +65,22 @@
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woff2Index != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff2{% if hash %}?v={{ hash }}{% endif %}") format("woff2")
url("{{ fontPath }}{{ fontName }}.woff2?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("woff2")
{%- set nothing = formats.splice(woff2Index, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woffIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff{% if hash %}?v={{ hash }}{% endif %}") format("woff")
url("{{ fontPath }}{{ fontName }}.woff?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("woff")
{%- set nothing = formats.splice(woffIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if ttfIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.ttf{% if hash %}?v={{ hash }}{% endif %}") format("truetype")
url("{{ fontPath }}{{ fontName }}.ttf?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("truetype")
{%- set nothing = formats.splice(ttfIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if svgIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.svg{% if hash %}?v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
{%- endif %}
}
Expand Down Expand Up @@ -185,11 +186,21 @@
</head>
<body>
<h1>List Icons</h1>
<div class="icons" id="icons">
<h3>Class</h3>
<div class="icons" id="icon-classes">
{% for glyph in glyphs %}
<div class="icons__item">
<i class="{{ className }} {{ className }}-3x {{ className }}-{{ glyph.name }}"></i>
<span>{{ className }}-{{ glyph.name }}</span>
<i class="{{ className }} {{ className }}-3x {{ className }}-{{ glyph.name }}"></i><br />
<span>.{{ className }}-{{ glyph.name }}</span>
</div>
{% endfor %}
</div>
<h3>Ligature</h3>
<div class="icons" id="icon-ligatures">
{% for glyph in glyphs %}
<div class="icons__item">
<i class="{{ className }} {{ className }}-3x">{{ glyph.unicode[1] }}</i><br />
<span>{{ glyph.unicode[1] }}</span>
</div>
{% endfor %}
</div>
Expand Down
10 changes: 5 additions & 5 deletions templates/template.scss.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
font-style: normal;
font-weight: 400;
{% if formats.indexOf('eot')>-1 -%}
src: url("{{ fontPath }}{{ fontName }}.eot{% if hash %}?v={{ hash }}{% endif %}");
src: url("{{ fontPath }}{{ fontName }}.eot?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}");
{%- endif -%}
{%- set eotIndex = formats.indexOf('eot') -%}
{%- set woff2Index = formats.indexOf('woff2') -%}
Expand All @@ -21,22 +21,22 @@
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woff2Index != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff2{% if hash %}?v={{ hash }}{% endif %}") format("woff2")
url("{{ fontPath }}{{ fontName }}.woff2?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("woff2")
{%- set nothing = formats.splice(woff2Index, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if woffIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.woff{% if hash %}?v={{ hash }}{% endif %}") format("woff")
url("{{ fontPath }}{{ fontName }}.woff?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("woff")
{%- set nothing = formats.splice(woffIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if ttfIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.ttf{% if hash %}?v={{ hash }}{% endif %}") format("truetype")
url("{{ fontPath }}{{ fontName }}.ttf?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}") format("truetype")
{%- set nothing = formats.splice(ttfIndex, 1) -%}
{%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
{%- endif -%}
{%- if svgIndex != -1 -%}
url("{{ fontPath }}{{ fontName }}.svg{% if hash %}?v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
{%- endif %}
}

Expand Down

0 comments on commit f39d2c1

Please sign in to comment.