Ryan McGeary Posted June 27, 2017 Share Posted June 27, 2017 With the new features in Alfred Snippets, I'm considering consolidating all my snippets from aText into Alfred. One feature that I use often in aText is the ability to embed a snippet inside another snippet expansion. This allows me to treat smaller snippets as variables that can be reused in other larger snippets. Is this possible with Alfred's Snippets? tullyhansen, dfay and timpish 3 Link to comment
Vero Posted June 28, 2017 Share Posted June 28, 2017 @Ryan McGeary Welcome to the forum In a standard snippet, you can use dynamic content, which could include dynamically inserting clipboard content, or date and time: https://www.alfredapp.com/help/features/clipboard/dynamic-placeholders/ However, for something more advanced, you'd be better off using a snippet trigger object, which was added in Alfred 3.4. You can use the snippet trigger object to trigger a workflow, where you can add any number of pop-up prompts or scripts to add further text. If you're using Alfred 3.4, take a look at this guide to discover how to use the Snippet Triggers: https://www.alfredapp.com/help/workflows/triggers/snippet/snippet-triggers-with-dynamic-inputs/ Another example we've created runs a small script in the middle to define whether it's morning, afternoon, evening or night and starts the pasted snippet with the appropriate greeting (e.g. "Good morning!"). There are so many options, but you'll most likely want to use something like the List Filter example in the guide above. Don't hesitate to ask if you need any help, as this is a new feature and I'm still in the process of creating documentation and examples for it! Cheers, Vero Link to comment
Ryan McGeary Posted June 28, 2017 Author Share Posted June 28, 2017 @Vero Thanks for chiming in, but I've already previewed the specific guide you're referring to. What I'm missing is how to insert the contents of multiple snippets into one over-arching wider piece of content. i.e. What workflow action gathers other snippets by name? And how do I gather multiple snippets and combine them into one larger snippet including multiple other snippet inputs? I guess I failed to find that. The whole notion of snippet workflows sounds really powerful for certain tasks, but it also feels quite convoluted from the perspective of just combining smaller snippets into one larger snippet. Maybe a more concrete example will help. Let's say that I have two small snippets: one for my business address and one my business Tax Identification number: .addr = 123 Fake St, Denver, CO 80014 .taxid = 12-3456789 Just like I can insert a {date} or {clipboard} into another larger snippet, I'd also really like to build a snippet that can output the combination of other snippets (using them like variables). Here's a somewhat contrived example of what I'd ideally be looking to do: Thank you for your business. Please send payment to: {snippet:.addr}. My business Tax ID is {snippet:.taxid} And to be more clear, these snippets might be further nested. e.g. I'd prefer my .addr snippet to be composed of smaller snippets like .as = (address street), .ac = (address city), and .az = (address zip), because I often use those to fill in forms that require them to be separated. Link to comment
Vero Posted June 28, 2017 Share Posted June 28, 2017 @Ryan McGeary That's a great example, and confirms I'd understood your original suggestion perfectly. We actually have a ticket to look at exactly this for a future release. I just didn't articulate this as well as I could've done, and was providing suggestions of how you can do something similar using the already-available features in the meantime Keep an eye out for upcoming releases! Cheers, Vero timpish and tullyhansen 2 Link to comment
tullyhansen Posted September 28, 2017 Share Posted September 28, 2017 Just chiming in here to say I came looking for info on whether Alfred could do exactly this sort of snippet nesting, and I'm excited to here it's coming down the line – eagerly refreshing the beta Update tab now! (Congrats on getting 3.5 out the door, too!) Ryan McGeary 1 Link to comment
magiCAD Posted February 1, 2018 Share Posted February 1, 2018 +1 on this feature. I'm definitely looking forward to seeing this being implemented. Can you share any updates on this @Vero? Ryan McGeary 1 Link to comment
celina Posted February 15, 2018 Share Posted February 15, 2018 Also looking forward to seeing this feature implemented so I can break free of TextExpander. Ryan McGeary 1 Link to comment
tullyhansen Posted July 9, 2018 Share Posted July 9, 2018 (edited) Just came back to give this a loving bump (as I go to update hard-coded URLs in older snippets after a domain change) – would love nested snippets (within snippets interface itself) to get a look-in whenever possible! Keep up the great work regardless. ❤️ (realising after posting that this likely isn't the right category to be considered a feature request… ?) Edited July 9, 2018 by tullyhansen dfay 1 Link to comment
ryqiem Posted October 23, 2018 Share Posted October 23, 2018 A loving bump from me too – this would be awesome for my workflows! Ryan McGeary 1 Link to comment
aaron Posted January 22, 2019 Share Posted January 22, 2019 Another +1. This is the last missing piece needed before moving all of my text expansion snippets into Alfred. Link to comment
John A Posted September 20, 2019 Share Posted September 20, 2019 +1 — Any update on whether this feature is still in the works? Thanks so much! Link to comment
cstreet Posted October 1, 2019 Share Posted October 1, 2019 +1 — Also looking for update on whether this feature is still in the works? Link to comment
xs2 Posted October 16, 2019 Share Posted October 16, 2019 +1 should not be to complicated to be included in the last two years?! I'd like to use this instead of textexpander, however nasted snippets would be a must have Link to comment
dfay Posted October 16, 2019 Share Posted October 16, 2019 I've moved all my snippets from TextExpander to Alfred, and it's actually pretty easy to create the equivalent of a nested snippet using snippet triggers in a workflow . Not as simple as in TE but easy to do if you don't anticipate continuously creating a lot of new ones (which is still easy but a bit of work.) Here's an example: https://www.dropbox.com/s/xu8afkqd4hfzgn2/nested snippets.alfredworkflow?dl=0 The snippet values are stored as environment variables and the first two snippet triggers show how to use them. The third shows how to use a list filter to replace the address value on the fly. vanderholm 1 Link to comment
packenbush Posted May 27, 2020 Share Posted May 27, 2020 +1, such an essential missing piece Link to comment
tullyhansen Posted June 2, 2020 Share Posted June 2, 2020 Hello Nested Snippet Thread, my old friend! Back to using Alfred snippets in a big way… despite the existence of Snippet Triggers as a workaround, would love to see nesting of built-in Alfred snippets inside of built-in Alfred snippets. (Even only one level deep, if it makes implementation less messy!) 💖 to the team! Link to comment
Andrew Posted June 5, 2020 Share Posted June 5, 2020 Pssst, just to let you know, Alfred 4.1 will be getting a {snippet:} placeholder to nest a snippet tullyhansen, Terminal, Ryan McGeary and 4 others 6 1 Link to comment
tullyhansen Posted June 23, 2020 Share Posted June 23, 2020 OMG @Andrew I came here to post this!! Thank you!! 🙌🙌🙌 Happy three-year anniversary to this thread, indeed! Link to comment
Andrew Posted June 24, 2020 Share Posted June 24, 2020 @tullyhansen and... oops, that should read {snippet:} in the change log Link to comment
Chris Messina Posted May 27, 2021 Share Posted May 27, 2021 On 10/15/2019 at 10:44 PM, dfay said: The snippet values are stored as environment variables and the first two snippet triggers show how to use them. The third shows how to use a list filter to replace the address value on the fly. How does one trigger or use your Nested Snippets workflow? Link to comment
Vero Posted May 28, 2021 Share Posted May 28, 2021 18 hours ago, Chris Messina said: How does one trigger or use your Nested Snippets workflow? You'll need to set keywords for the Snippet Triggers as these are stripped from the workflow to avoid clashing with your own. For example, I've set them to these... Just keep in mind the shared prefix in your Snippet Triggers setup, so I've only set them to "tw" and so on, and the \\ prefix is set globally for all my snippet triggers. You've no doubt figured that in @dfay's example, you can set the name and address in the environment variables under the [x] in the top right of the workflow canvas You can read more about the snippet triggers object, or see the few scenarios with dynamic content within the snippets as examples too. Nested snippets and snippets trigger based workflows generally are really good fun and ever so useful. dfay and Chris Messina 2 Link to comment
Chris Messina Posted May 28, 2021 Share Posted May 28, 2021 5 hours ago, Vero said: Nested snippets and snippets trigger based workflows generally are really good fun and ever so useful. Wow, ok — makes sense now. Thanks! I can see the source of my confusion since the Snippets Manager doesn't really connect to the Workflow Snippet Triggers (i.e. by cross-linking or perhaps by listing them as a special collection in the Snippets Manager). It would be handy if the Snippets Manager listed Workflow-derived Snippet Triggers! dfay 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now