Get started with dot CDN

MIT licensed

The dot library simplifies chaining and accessing methods and properties of objects by allowing the use of a dot notation syntax instead of the traditional bracket notation.

Tags:
  • template

Stable version

Copied!

How to start using dot CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with dot CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/dot/1.1.3/doT.min.js"></script>
</head>
<body>
  <script>
    // Define the template
    const template = `
      <p>Name: {{name}}</p>
      <p>Age: {{age}}</p>
      <p>Greeting: {{greeting}}</p>
    `;

    // Compile the template
    const templateFunction = doT.template(template);

    // Data to be used in the template
    const data = {
      name: "John Doe",
      age: 30,
      greeting: "Hello, World!"
    };

    // Render the template with the data
    const renderedTemplate = templateFunction(data);

    // Output the rendered template
    document.body.innerHTML = renderedTemplate;
  </script>
</body>
</html>
Copied!
Copied!

All versions