How to use short codes with arguments I came across this. That shows how you can get a code like {{ cta }} populated with any data you want, and get that inserted in a template. I want the same sort of solution, but for content. In other words, let's say I have a blog post, I want to be able to add:

{{ cta }}


or

[[ cta ]]


or any convention that works. But the end result is that I must be able to populate the variable via code.

BACKGROUND INFO

I have a bunch of events on my website. I often write blog posts where I refer to events on the site. To add dynamic content to my blog posts, I'd love to simply add things like:

{{ events || from:19dec2014 || to: 23dec2018 }}


I would then populate these with the correct information.

Any ideas on how to do this correctly?
Try the Shortcode module. It was the among the first hits when I searched for Drupal 8 shortcode.



For the second part of your question I'd recommend Insert View. You can embed a view via a short code in your content and also pass arguments to it.


  Insert View is a filter that allows users to embed content lists
  generated by the Views module into node bodies and blocks using
  relatively simple tag syntax.
  
  Why would you want to use an Insert View tag when you could just
  invoke a view using PHP? Simple. When you want to allow users to
  insert views or edit content on a page with an inserted view without
  granting them permission to use PHP.
  
  The tag syntax is [view:name=display=args]
  
  The parameters are: view name, view display id, view arguments.
  
  Valid examples:
  
  
  [view:my_view] is replaced by the content listing.
  [view:my_view=my_display] invokes the view using the specified display.
  [view:my_view=my_display=arg1/arg2/arg3] invokes the view using the specified display and passes arg1, arg2 and arg3 to the view.
  [view:my_view==arg1/arg2/arg3] passes arg1 to the view and will use the "default" display set for the view.