Skip to content

Instantly share code, notes, and snippets.

@ghinda
Last active March 4, 2020 14:10
Show Gist options
  • Save ghinda/32616bc9466f769a7f570e07db57463e to your computer and use it in GitHub Desktop.
Save ghinda/32616bc9466f769a7f570e07db57463e to your computer and use it in GitHub Desktop.
Gorgias Templates CRM plugin
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<textarea cols="100" rows="10"></textarea>
<p>
Test variable support with this template:
<pre><code>
to.first_name: {{to.first_name}}
from.first_name: {{from.first_name}}.
airbnb.phone_number: {{airbnb.phone_numer}}
airbnb.host.first_name: {{airbnb.host.first_name}}
</code></pre>
<p>
<script>
const vars = {
from: {
first_name: 'Ionuț'
},
to: {
first_name: 'John'
},
airbnb: {
phone_numer: '+123456789',
host: {
first_name: 'Marie'
}
}
}
function encodeVars (v = {}) {
return encodeURIComponent(JSON.stringify(v))
}
const $textarea = document.querySelector('textarea')
$textarea.setAttribute('data-gorgias-variables', encodeVars(vars))
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment