mirror of
https://github.com/TheThomaas/my-online-cookbook.git
synced 2026-01-09 19:41:38 +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)
|
||||
config.addFilter('arrayToString', function(value) {
|
||||
return value.join('£');
|
||||
return encodeURI(value.join('£'));
|
||||
});
|
||||
|
||||
/* 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>
|
||||
{% endfor %}
|
||||
</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 == "" %}
|
||||
<div class="c-recipe__additional-info">
|
||||
{% if time %}
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
<script>
|
||||
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>
|
||||
{% endblock %}
|
||||
Loading…
Reference in a new issue