If that doesn't help I would recommend opening a new community forum discussion with your last comment or ask your question in the HubSpot Developer Slack https://designers.hubspot.com/slack
Then you can use this and other variables in your Javascript module file, which you should consider best practice, since it increases readability of your code quite a bit and allows unit testing and other state of the art best-practices.
module.js
const data = JSON.parse(document.getElementById("data").text)
console.log('From HubL generation', data.country_filter)
Then you can use this and other variables in your Javascript module file, which you should consider best practice, since it increases readability of your code quite a bit and allows unit testing and other state of the art best-practices.
module.js
const data = JSON.parse(document.getElementById("data").text)
console.log('From HubL generation', data.country_filter)
HI @ruanngabriel, what is your use-case here? You can certainly use HubL to inject values into a javascript function as long as this ends up being valid JS.
For a very simple example, if I want to log the value of my name to the console, I can do something like this:
{% set myName = "Connor" %}
{% if myName %}
<script type="text/javascript">
console.log("{{ myName }}")
</script>
{% endif %}
Here are two screenshots that show this works:
Let me know if I'm misunderstanding you and I'd be happy to take a further look!
Hi @ruanngabriel external in what way? You attach a JS file hosted externally with HubL in it to a HubSpot hosted page? If so, no you cannot do that. You can write HubL inside of Design Manager hosted JS files, custom modules, and the head HTML/ footer HTML of pages/content settings but that is it.
If that doesn't help I would recommend opening a new community forum discussion with your last comment or ask your question in the HubSpot Developer Slack https://designers.hubspot.com/slack
@louischausse , thanks for referring me to Slack. I was able to find the solution to my query there. It was by using Zapier's Webhooks to insert values to my HUBDB.