FiB3 / ssjs-vsc

VSCode extension to streamline Server Side JS development for SalesForce Marketing Cloud.
https://fib3.vercel.app/ssjs-vsc
BSD 4-Clause "Original" or "Old" License
7 stars 0 forks source link

docs: dev / prod tokens definition / use case? #4

Closed JoernBerkefeld closed 7 months ago

JoernBerkefeld commented 11 months ago

whats that for? is that supposed to be templating / auto-replacement logic? if yes, could you provide a real-life example to make it easy to understand?

you mention it on https://fib3.github.io/ssjs-vsc/settings/ and on https://fib3.github.io/ssjs-vsc/use/ but neither description is giving actual examples

FiB3 commented 11 months ago

This one can be pretty useful in two cases:

I will add a more thorough explanation to the page.

A simple example though:

<script runat=server>
   var IS_PROD = {{IS_PROD}};
   var MC_SUBDOMAIN = "{{SUBDOMAIN}}";
   var CLIENT_ID = "{{CLIENT_ID}}";
   var CLIENT_SECRET = "{{CLIENT_SECRET}}";

</script>
{ //...
   {
     "dev-tokens": {
      "IS_PROD": false,
      "MC_SUBDOMAIN": "mc-dummy-subdomain",
      "CLIENT_ID": "cl-id-12345",
      "CLIENT_ID": "cl-secret-98765"
    },
    "prod-tokens": {
    },
    /...
 }
JoernBerkefeld commented 11 months ago

ok, that is in fact what we call templating in mcdev. had a feeling but wasn't sure. I'm assuming you use Mustache? You might want to consider using 3 curly brackets because that ensures the text is used as-is. otherwise it might end up doing some unwanted extra conversions...

FiB3 commented 11 months ago

Yup, it's templating & Mutache. The name "tokens" is a bit of a legacy thing.

Good idea, GTL probably will not be supported in the current implementation. But that way I will probably need to choose another templating package.

FiB3 commented 11 months ago

I am adding this to Usage tab on the page.

FiB3 commented 11 months ago

I am preparing a new version of the extension, that has an option to set the Mustache Tags. image

JoernBerkefeld commented 11 months ago

good thinking :)

FiB3 commented 11 months ago

Deployed yesterday in v0.2.0.

FiB3 commented 7 months ago

There is way more documentation on this topic now: https://fib3.vercel.app/ssjs-vsc/4_templating Also, since v0.4.4 (will be pre-released today) you can set these in the Config Panel.