0.0.14 • Published 10 months ago

daton-template-snippet v0.0.14

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

Get started with Daton Template Snippet

Install Daton Template Snippet

First, we will need to add Daton template snippet file in your frontend.

Add the following script tag in your website:

<script type="text/javascript" src="https://unpkg.com/daton-template-snippet@latest/dist/daton-template-snippet.js"></script>

The script injects a global Daton variable in the window object.

Initiate the Daton template API:

Then, on any HTML template, on either click of a button or any other event, you can initiate the Daton template API.

<!DOCTYPE html>
<html>
  <head>
    <title>Sample HTML Template</title>
  </head>
  <body>
    <p><button onclick="loadDaton()">Load Daton!</button></p>
  </body>
</html>
<script type="text/javascript" src="https://unpkg.com/daton-template-snippet@latest/dist/daton-template-snippet.js"></script>
<script type="text/javascript">
    function loadDaton() {
        window.Daton.init({
            apiKey: "<API_KEY>",
            baseSourceName: "<SOURCE_NAME>",
            newSourceNamePrefix: "<PREFIX>"
        });
    }
</script>

onSuccess and onError callbacks

You can also pass onSuccess and onError callbacks to the init function.

function loadDaton() {
    window.Daton.init({
        apiKey: "<API_KEY>",
        baseSourceName: "<SOURCE_NAME>",
        newSourceNamePrefix: "<PREFIX>",
        onSuccess: () => {
            console.log("success")
        },
        onError: (err) => {
            console.log("error")
        }
    });
}

Development

To run the project locally, run the following command:

npm run start

Build

To build the project, run the following command:

npm run build

To publish the package

To publish the package, run the following command:

  1. Update the version in package.json
  2. Run the following command:
npm publish --access public
  1. Go to https://www.npmjs.com/package/daton-template-snippet and check if the package is published successfully.
0.0.13

10 months ago

0.0.14

10 months ago

0.0.11

10 months ago

0.0.12

10 months ago

0.0.3

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago