Hello guys i need import just some functions of my js file, without import all the file with lib ? it’s possible something like this:
{% javascript %}
import { useCall } from 'lib/js/test.js';
useCall(test);
{% endjavascript %}
Hello guys i need import just some functions of my js file, without import all the file with lib ? it’s possible something like this:
{% javascript %}
import { useCall } from 'lib/js/test.js';
useCall(test);
{% endjavascript %}
Currently not, the javascript tag does not interpret javascript. It allows you to put verbatim javascript on your page, but with the extra addition that you can add template variables and use all template language additions. After rendering, the text is placed on the page.
Example:
{% javascript %}
console.log("Current page", {{ id }});
console.log("Current user", {{ m.acl.user }});
{% endjavascript %}
In order to support something like this we have to be able to run the javascript itself I think.
thanks.
It would probably possible to add something like this by integrating something like deno (https://deno.land) into a custom zotonic tag (Create a custom tag @ Zotonic). That way you could can let deno compile the desired javascript, which is then embedded on the page. It would then even support typescript.