mirror of
https://github.com/TheThomaas/my-online-cookbook.git
synced 2026-01-10 20:01:47 +00:00
Encode ingredients to handle special characters
This commit is contained in:
parent
f58a99b04b
commit
20dac4790c
|
|
@ -63,7 +63,7 @@ module.exports = config => {
|
||||||
|
|
||||||
// This workaround is needed so we can transform it back into an array with Alpine (we can't split on "," as it can be included within the items)
|
// This workaround is needed so we can transform it back into an array with Alpine (we can't split on "," as it can be included within the items)
|
||||||
config.addFilter('arrayToString', function(value) {
|
config.addFilter('arrayToString', function(value) {
|
||||||
return value.join('£');
|
return encodeURI(value.join('£'));
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Shortcodes */
|
/* Shortcodes */
|
||||||
|
|
|
||||||
5400
package-lock.json
generated
5400
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,7 +11,7 @@
|
||||||
<a class="c-tags__tag" href="/tags/{{ tag | noEmoji | slug }}">{{ tag }}</a>
|
<a class="c-tags__tag" href="/tags/{{ tag | noEmoji | slug }}">{{ tag }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="c-recipe__ingredients-wrapper" x-data='{currentServings: {{ servings if not servings == "" else false }}, ingredients: "{{ ingredients | arrayToString }}".split("£") }'>
|
<div class="c-recipe__ingredients-wrapper" x-data='{currentServings: {{ servings if not servings == "" else false }}, ingredients: decodeURI("{{ ingredients | arrayToString }}").split("£") }'>
|
||||||
{% if time or not servings == "" %}
|
{% if time or not servings == "" %}
|
||||||
<div class="c-recipe__additional-info">
|
<div class="c-recipe__additional-info">
|
||||||
{% if time %}
|
{% if time %}
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function adaptQuantity (ingredient, originalServings, currentServings) {
|
function adaptQuantity (ingredient, originalServings, currentServings) {
|
||||||
return ingredient.replace(/(\d|\.|,)+/, match => Number(Math.round(parseFloat(match) * currentServings / originalServings + 'e' + 2) + 'e-' + 2));
|
return ingredient.replace(/(\d|\.|,)+/, match => Number(Math.round(parseFloat(match.replace(',', '.')) * currentServings / originalServings + 'e' + 2) + 'e-' + 2));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Loading…
Reference in a new issue