Create file from template

Download for free
Get it now

What if you want to create a relatively complex text file in Switch? Say… something like an XML file, or a JDF, or a complex JSON file. Yes, you can write a custom script for this, but even with a script, doing this is still very messy and a lot of hard and painstaking work. If only there would be a way to make that easier…

Wait a minute, when you’re generating HTML files for a web site, isn’t that very much the same problem? How do those systems deal with that? Turns out that smart people invented something called a templating engine. You provide a template and can then insert variables in that template in a structured way. Modern templating engines even allow you to create loops, insert conditionals and so on.

This Switch app uses a templating engine – Embedded JavaScript templating, or EJS – to do exactly this. The app has different ways to specify where the template is and to specify input variables for the template. It builds the output from the template injected with these variables and then outputs it according to what you need in the rest of the workflow.

What can you do with this?

The sky is the limit! :) However, some practical examples would be:

  • Insert private data (and other metadata from a job) into a template to generate a text or HTML email body.
  • Use an incoming JSON file with information about an order and generate a production follow-up email for it.
  • Create a JDF template and insert job information for output to an output device or production workflow.
  • Write log information to a CSV file (yes, the app supports appending to an existing file).
  • Output a JSON, XML,... file to communicate with an external service.

Can't I do this with a script?

Of course you can write a custom script for this (well, if you have access to the scripting module that is). But scripts to write complex text files very quickly become messy. Using this app has the advantage that you separate the business logic from the presentation. Use a script to attach information to a job, or to generate a custom JSON file. Then use this app and a custom template to format your information into the output format you want. Doing things this way both your script and the template become simpler and are more easily maintainable.

 

Compatibility
Switch Version Required:2020 Fall or higher
Platform:Windows, Mac
3rd Party Compatibility:   
5.0
5

3 reviews
Jimmy H. (Denmark) installed this app.
5
Reviewed on 18 Dec 2023.

I found this program when I need to create an order confirmation based on JSON from an MIS system. And it fit perfectly into my workflow.
I just needed to learn a bit about EJS-templates.
A nice touch is that is also possible to use Switch Private Data in the templates.

Magnus S. (Sweden) installed this app.
5
Reviewed on 18 Nov 2023.

This is one of the best free apps in the App store. We use it for all our flows to create csv-log files to be able to track the usage of our flows (and take actions for flows that are not beeing used for a long time). We also use it to make different lists for batch jobs etc. A tip if you are batch-running alot of files through the app, whick can cause writing errors, can be to space jobs 1 sec apart with the Hold job app.

Yves B. (France) installed this app.
5
Reviewed on 22 Sep 2022.

This is a great app that makes it easy for me to generate jdf's on the fly, huge possibilities for a very easy to use app.

App creator

Four Pees
Support
+32 9 237 10 00
Online support

App creator

Four Pees
Support
+32 9 237 10 00
Online support