Stream: tooling
Topic: issue with URL containing & character
Jose Costa Teixeira (Nov 03 2020 at 08:42):
I want to add something to my template.
A small script at the end that does a GET <somegoogleforms>?parameter1¶meter2¶meter3
Jose Costa Teixeira (Nov 03 2020 at 08:44):
This is now giving me a lot of unable to parse character reference '"''
. what can I do to remove this?
Lloyd McKenzie (Nov 03 2020 at 16:34):
What kind of script? In the template where?
Jose Costa Teixeira (Nov 03 2020 at 16:50):
in one of my templates. It's the script to provide feedback which calls a url with a couple of parameters
Lloyd McKenzie (Nov 03 2020 at 19:24):
So the issue is that you want to substitute a URL into the rendered page, but you want the content to be parameterized - and you're trying to do that using Liquid and running into issues?
Jose Costa Teixeira (Nov 03 2020 at 20:00):
yes
Lloyd McKenzie (Nov 03 2020 at 21:26):
What's your liquid?
Jose Costa Teixeira (Nov 03 2020 at 22:27):
not sure if this is what you're asking, but this is the part of the code that adds the liquid
{% if site.data.features.feedback.parameters %}
{% for parm in site.data.features.feedback.parameters %}
feedbackurl = feedbackurl + "&";
feedbackurl = feedbackurl + {{ parm.name }} + '=' + {{ parm.value }}
{% endfor %}
{% endif %};
Lloyd McKenzie (Nov 03 2020 at 23:05):
Your & needs to be &
Lloyd McKenzie (Nov 03 2020 at 23:05):
blah. &amp;
Lloyd McKenzie (Nov 03 2020 at 23:05):
blah &
Lloyd McKenzie (Nov 03 2020 at 23:05):
I.e. escape it as required in HTML.
Jose Costa Teixeira (Nov 11 2020 at 21:05):
I did that, it resolves the qa issue, but now the url does not work because the & is encoded. The url should be
...¶m1=x¶m2=y
but it is
...&param1=x&param2=y
How do I unencode it?
Lloyd McKenzie (Nov 11 2020 at 21:37):
What do you mean?
Jose Costa Teixeira (Nov 11 2020 at 21:50):
My script above creates a parametrized URL. If I change it to
{% if site.data.features.feedback.parameters %}
{% for parm in site.data.features.feedback.parameters %}
feedbackurl = feedbackurl + "&";
feedbackurl = feedbackurl + {{ parm.name }} + '=' + {{ parm.value }}
{% endfor %}
{% endif %};
then my parametized url no longer works, because the & has become &
Jose Costa Teixeira (Nov 11 2020 at 21:52):
so apparently i need to escape the URL to avoid QA issues, but after jekyll runs, i need it to be &
and not &
-
this is not html content, it is a url.
Lloyd McKenzie (Nov 11 2020 at 22:01):
@Eric Haas :)
Eric Haas (Nov 11 2020 at 22:50):
have you looked at the URI Escape filter : https://jekyllrb.com/docs/liquid/filters/ ?
I am not sure what you are trying to achieve.... if you want the QA to ignore this URL then wrap it in a code block
e.g base?foo=bar&fo02=bar2
Jose Costa Teixeira (Nov 12 2020 at 10:56):
What I need: The final html must have, at the end of each page, a small script, and that script contains a "&"
Jose Costa Teixeira (Nov 12 2020 at 10:57):
If I escape it, it gets published as an escaped &
If I don't escape it, it gives me a ton of QA errors
Jose Costa Teixeira (Nov 12 2020 at 10:58):
So I need a way to pass that "&" all the way through the publication without giving me the QA error
Jose Costa Teixeira (Nov 12 2020 at 19:40):
Any ideas @Eric Haas ?
Eric Haas (Nov 12 2020 at 20:14):
use a custom template?
Jose Costa Teixeira (Nov 12 2020 at 20:22):
This is in a custom template.
Last updated: Apr 12 2022 at 19:14 UTC