Skip to content

Ability to specify fragment placement in templates #948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
simonw opened this issue Apr 23, 2025 · 1 comment
Open

Ability to specify fragment placement in templates #948

simonw opened this issue Apr 23, 2025 · 1 comment
Labels
enhancement New feature or request fragments

Comments

@simonw
Copy link
Owner

simonw commented Apr 23, 2025

So you can construct a template that includes fragments at specific point within that template.

Suggested https://mastodon.social/@webology/114387919299723272

Where $1 might be the output from the first fragment, and $2 would be the output from the second fragment when given a template name.

I don't love that syntax, but maybe something more from python's format would be better. or even -f var_name=github:simonw/symbex and var_name is the template's variable to be replaced.

@simonw simonw added enhancement New feature or request fragments labels Apr 23, 2025
@jefftriplett
Copy link

jefftriplett commented Apr 23, 2025

I'm doing this as a manual step with Ned's wonderful cogapp project today and then eventually piping the results back into LLM.

I have blocks these using symbex:

<example-model>
# [[[cog
import subprocess
output = subprocess.check_output(["uvx", "symbex", "--exclude", ".stversions", "--no-file", "MyDjangoModel"], text=True)
print(output.strip())
# ]]]
# [[[end]]]
</example-model>

We could skip all of that though and use your fragment templates if there were an easier way to template them. Like maybe this:

Please read our example Django Model and Django ModelAdmin

<example-model>
{$1}
</example-model>

<example-model-admin>
{$2}
</example-model-admin>

Given this this Django model, please create a ModelAdmin for our model:

<model>
{$3}
</model>

<instructions>
- please read our example-model and example-model-admin for ideas
- use our `model` to create a new `model-admin`
- ... 
</instructions>

<model-admin>
...
</model-admin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fragments
Projects
None yet
Development

No branches or pull requests

2 participants