Share settings with ENV and the [key] syntax
ENV(name, value) registers a value for the whole page and ENV(name) reads it. Wherever jComponent accepts a text that may contain [name] (for example the URL of AJAX() and IMPORT()), the placeholder is replaced with the value, so you set the address of your API in one place. '[name]'.env() does the same replacement on any string.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jComponent</title>
<link rel="stylesheet" href="//cdn.componentator.com/spa.min@20.css" />
<script src="//cdn.componentator.com/spa.min@20.js"></script>
</head>
<body>
<p class="out"></p>
<script>
ENV('api', '/api/v1');
ENV('version', '20');
$('.out').text('[api]/users?v=[version]'.env());
</script>
</body>
</html> Try it in your browser
Edit the example and run it. It runs in an isolated frame in your browser; nothing is sent to our server.
Preview