From 8bcb4f066f8ae8b17dc70e6238708e5a97422c0c Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Oct 2021 15:18:05 -0300 Subject: [PATCH] las plantillas de liquid.js se incorporan en env.js --- assets/templates/alert.html | 14 ++++++++------ assets/templates/results.html | 34 ++++++++++++++++++---------------- env.js | 17 +++++++++++++++++ 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/assets/templates/alert.html b/assets/templates/alert.html index b520708..1ef923d 100644 --- a/assets/templates/alert.html +++ b/assets/templates/alert.html @@ -1,7 +1,9 @@ - +{%- endraw -%} diff --git a/assets/templates/results.html b/assets/templates/results.html index 2473966..65c0e11 100644 --- a/assets/templates/results.html +++ b/assets/templates/results.html @@ -1,17 +1,19 @@ -
-
- {% for item in results %} - + {% endfor %} +
+
+{%- endraw -%} diff --git a/env.js b/env.js index b38f2f9..711fa4f 100644 --- a/env.js +++ b/env.js @@ -10,3 +10,20 @@ window.env = { window.site = { "i18n": {{ site.i18n | jsonify }} } + +{%- comment -%} + Para agregar plantillas que se procesan con JS, las agregamos en + Liquid dentro de assets/templates/ y luego las importamos acá, de forma + que estén disponibles para JS sin tener que descargarlas. + + Es importante que la plantilla esté envuelta por el tag `{% raw %}`, + para que no sea procesado en el momento de generar env.js, sino en el + navegador. +{%- endcomment -%} +{%- capture alert %}{% include_relative assets/templates/alert.html %}{% endcapture -%} +{%- capture results %}{% include_relative assets/templates/results.html %}{% endcapture -%} + +window.templates = { + "alert": {{ alert | markdownify }}, + "results": {{ results | markdownify }}, +}