-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
Wrap + Include #452
Comments
Wrap takes a function reference, include returns a text, so it's not a function reference. |
I see. Is it possible to some block-level text to an include function? Thanks for your reply! |
Sorry, I don't understand this question. Could you elaborate? |
I have two templates
# {{ $1 }}
{{ $$ }} and I want it to become something like
|
So warp takes a reference to a function so I would believe that using an anonymous function could work in your case:
|
That works perfectly! Thank you! |
Things may have changed since I made this discussion, but as far as I can tell, wrap does take I've found that the following implementation works for me internal class IncludeW : IScriptCustomFunction
{
private readonly IncludeFunction _function = new();
public int RequiredParameterCount => _function.RequiredParameterCount;
public int ParameterCount => _function.ParameterCount;
public ScriptVarParamKind VarParamKind => _function.VarParamKind;
public Type ReturnType => _function.ReturnType;
public ScriptParameterInfo GetParameterInfo(int index)
{
return _function.GetParameterInfo(index);
}
public object Invoke(TemplateContext context, ScriptNode callerContext, ScriptArray arguments, ScriptBlockStatement blockStatement)
{
context.SetValue(ScriptVariable.BlockDelegate, blockStatement);
return _function.Invoke(context, callerContext, arguments, blockStatement);
}
public async ValueTask<object> InvokeAsync(TemplateContext context, ScriptNode callerContext, ScriptArray arguments, ScriptBlockStatement blockStatement)
{
await context.SetValueAsync(ScriptVariable.BlockDelegate, blockStatement);
return await _function.InvokeAsync(context, callerContext, arguments, blockStatement);
}
} Used like so
{{ wrap includew 'template' -}}
nested text
{{- end }} resulting in
|
How to combine wrap and include?
Example template. It is not possible to obtain
$$
insideTemplate
hereThe text was updated successfully, but these errors were encountered: