scriban / scriban

A fast, powerful, safe and lightweight scripting language and engine for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to return a variable from inside a template

RogerW-VZC opened this issue · comments

As an example, I have a generic template "Make a service interface declaration"
Inside the file, I can name the interface "ILotteryResultsService" based on a passed in variable containing "lottery_results" being the name of a database view, and then reformatted using a function in the template.
I'd like the template to be say "Oh, and save this output as "ILotteryResultsService.cs" to keep the logic all in one place.

I think this would work if the global ScriptObject (for example) could be written back to.
But I can't find a syntax that seems to do it.
I can update a variable that came from the ScriptObject
e.g. {{ fileName = "ILotteryResultsService.cs" }}
But that doesn't then appear in the CurrentGlobal ScriptObject, which retains the original value.

Never mind. I'd missed typed the variable name in my template.
When I fixed the typo, it started showing up.