chapbook
chapbook copied to clipboard
Add support for variable-displaying strings in custom inserts
Right now, custom inserts don’t work with a string that includes a variable to be displayed:
{custom insert: “the value of displayVariable is {displayVariable}”}
That’s prevented because, in render-inserts.ts
render()
lines 141 and on, the parsing accepts }
if it’s inside a string, but any {
signals the start of a new insert, even inside a string.
I’m thinking of use cases where I’d like the custom insert to modify text that then will be processed by engine.template.render()
.
If there’s no negative repercussions, could we let inserts include }
inside a string?
Hmm. I'd call it a bug that it doesn't handle {
inside of a string argument, so I created an issue to track that here: https://github.com/klembot/chapbook/issues/176
Whether we allow variable interpolation... not sure. I lean more towards giving a custom insert a way to interpolate variables instead of doing it for the insert automatically.