I think this is best explained withe the actual use case.

I have a template file for a custom capture, that looks like this:

**** Daily Plan %T
    + [ ] The 3 most important tasks [/]
      - [ ] %^{1st Priority}
      - [ ] %^{2nd Priority}
      - [ ] %^{3rd Priority}

I would like it to look like this (but functional)

**** Daily Plan %T
    + [ ] The 3 most important tasks [/]
      - [ ] %^{1st Priority}
      - [ ] %^{2nd Priority}
      - [ ] %^{3rd Priority}
    + [ ] Ongoing Things
      - ( code to find any headlines tagged with :ongoing: ) 

I see from the template expansion page that I can put %(sexp) into a template, but I have no idea what that code should look like. I'm assuming an agenda search would be the most efficient? 

Any suggestions on how this could be done?

Cheers,
-- Steen