Is there any way to include the JSON response from element API in a template. Let's take the following example:
/case-studies.json returns:
{
data: [
{
title: "American Express",
color: "#0000ff",
url: "http://localhost:3340/index.php?p=case-studies/american-express"
},
{
title: "Bosch",
color: "#ffffff",
url: "http://localhost:3340/index.php?p=case-studies/bosch"
}
]
}
I want to known if I can include this JSON object into my template case-studies/index.html, so it looks like:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<...>
<script>
window.data = [
{
title: "American Express",
color: "#0000ff",
url: "http://localhost:3340/index.php?p=case-studies/american-express"
}, {...}
];
</script>
</body>
</html>
I just wanna avoid the first ajax call when I load the page for the first time by including the data in the HTML body. Further on, I will use Ajax calls instead.