Get triggering file structure in HTML email

Post Reply
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Get triggering file structure in HTML email

Post by gabrielp »

Is it possible to get this block in HTML emails instead of just plain text ones?



Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Get triggering file structure in HTML email

Post by freddyp »

[Job.NestedName:Indent=" ",Separator=]



Freddy
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Get triggering file structure in HTML email

Post by gabrielp »

freddyp wrote: [Job.NestedName:Indent=" ",Separator=]



Freddy


Wonderful! Thanks so much. Works well in a :



<p>

<span style="font-size:14px;">File Structure</span><br>

<pre style="display: block;font-family: Consolas,monaco,monospace;white-space: pre; margin: 0;max-width: 500px;overflow: visible;">{% spaceless %}

[Job.NestedName:Indent="ÂÂÂÂ",Separator=<br>]

{% endspaceless %}</pre>



</p>



I don't suppose there is a way to get to the end of a line that is indented. For example, if I wanted to indent with a and then close that indention with a ? or possibly specify the end of an indented string (a folder) with a trailing slash (but not the files inside)? If not, no worries. This works well enough.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Get triggering file structure in HTML email

Post by freddyp »

You can always write a script expression that uses s.getVariableAsString("[Job.NestedName]"). That returns the list of folders and files as a string, by default separated by a semi-colon and prefixed with 4 spaces per indentation level (I would change that to 1 space for what follows).



You can split the string to an array. You start off with an empty HTMLstring and you loop over the array and check if the indent level changes, ie the number of leading spaces changes. Here you see why I would use just 1 space: there is no point in counting by fours. A change of indent level is a trigger to insert (number of leading spaces goes up) or (number of leading spaces goes down).



At the end you return the HTML-formatted string. Note that "returning" a string in a script expression is not done by writing:



return HTMLstring;



but simply by writing:



HTMLstring;



If it is worth the trouble is your decision:)



Freddy
Post Reply