Filling out a standard template

drafts

#1

Hello

I am a student teacher and currently on placement. Along with a lot of teaching, I have to do a mountain of paperwork that requires the use of badly made standard templates.

What I was hoping to do was to use a text editor like drafts to type out my lesson plans etc then export them into the templates that I can then send away.

I’ve seen that there are different tags that can be put into draft templates to insert the first paragraph or a whole draft into a template but I can’t seem to find a way to break up the document more.

I don’t have to use drafts it is just the text editor I use at the moment. I have a Mac also if it can’t be done on IOS.

Many thanks to anyone able to help out.


#2

Can you share an example template, without content? Also is it a specific file format? E.g. a Word document, a PDF.


#3

Of course. Thanks very much for having a look.

The end file doesn’t have to be in any specific file format. As long as it is printable from a windows PC. If it can be a word doc then thats a bonus but not a necessity.


#4

If it just has to be printable then you could easily write in markdown and make a PDF. The trick will be to make sure you have the template in Drafts.


#5

How would I go about breaking the text in a Draft to fill out the different fields in the template?


#6

The point would be not to use it to fill in an existing template, but to generate a fresh document that matches the layout you require.

Here’s some MultiMarkdown showing how a table would look when the Draft content is converted to HTML. You could trigger a custom Shortcut to convert that into a PDF as @RosemaryOrchard suggested.

Expand for Screenshots

… but the tabular layout in the template isn’t simple.

As such, perhaps converting to a more tailored HTML layout would be better?

Here’s what I’m thinking. You could enter the content into your Draft under pre-configured headings; Drafts can even populate a template for you to give you those headings. Then using a custom Drafts action you could extract each section and insert those into some pre-built HTML (contained in the action), which could then trigger the custom Shortcut to create a PDF (again, from the same action), and you could even specify a naming convention and perhaps where to save, or straight to the share sheet.

As an example approach, if you wrote the content in Markdown with your sections labelled as level 1 Markdown headings, you could split the draft content by “#” and then effectively ignore the first line (assume you keep your initial template’s standard order), and then that goes on to populate your HTML content.

Hopefully you know enough about Drafts and Shortcuts to do this yourself, but if you feel that you do need more of a walkthrough example of this let me know and I’ll look at putting something together.

Hope that helps.


#7

Your certainly right about the mark down table. I have tried it before and it quickly got confusing for me unfortunately.

Your second idea seems like it could work really well! What I have done so far is convert the word doc into HTML and I can identify the points at which each section of text would need to go from drafts. However I don’t know how to code an action in drafts to split up the text by heading and then insert it into the HTML.

If you would be able to help it would be very much appreciated.


#8

Here’s what I put together. I actually think it turned out pretty much complete, but if not, hopefully it will be a solid starting point for you.

First of all here are two Drafts (specifically Drafts 5) actions that are intended to run against an empty draft. They just insert a block of text at the current cursor position.

Next are the two bits of automation that process the content of a templated draft. First is the Drafts action that extracts the data and builds the HTML. Second is the Shortcuts custom shortcut that the Drafts action calls to create and share the PDF. Make sure you have the Shortcuts shortcut installed before you try running the Drafts action.

The Drafts action parses the draft content and splits the sections based on the level 1 Markdown headings. It uses the heading and the section content to generate Drafts template tags, which can then be referenced in other places. Once the tags are generated, the HTML is generated using those placeholder tags (I fixed a few formatting issues that came through from the original template, so it should look even cleaner than the original with any luck).

At this point the Drafts action shows a preview. you can disable this once you are happy with the results.

Drafts Action Preview

After selecting continue, the Drafts action will trigger the Shortcuts custom shortcut, and will pass in the HTML.

The custom shortcut will convert the HTML to rich text and convert that into a margined PDF. It has to be portrait is the only restriction here. The shortcut includes another preview; again you can disable it if you wish.

Shortcuts PDF Quick Look

Finally the share sheet is opened for sharing the PDF.

Anyway, that’s basically it. Hopefully that’s the sort of thing you were after.


#9

That is amazing, thank you so much. It works brilliantly.


#10

Great. Glad it scratched the proverbial itch.

Hopefully others will also be able to make use of the principles and general approach to streamline generating other standardised content. I can see it being a good way to produce certificates, reports (like yours), (basic) invoices and the like.


#11

I must say that turned out pretty amazing.