Example #1
0
        internal static CompiledTemplate LoadTemplate(JinjaEnvironment environment, string templateText, IDictionary <string, object?> variableTemplate, string templateName, string?templatePath)
        {
            var rootScope = CompiledScope.CreateRootScope("GLOBALS", variableTemplate);
            var expr      = ToExpression(templateName, environment, templateText, rootScope);

            return(new CompiledTemplate(environment, ExpressionData.CreateCompiled(expr, rootScope), templateName, templatePath));
        }
Example #2
0
        internal object?Evaluate(string expressionText, IDictionary <string, object?> variables)
        {
            variables = variables ?? throw new ArgumentNullException(nameof(variables));
            var rootScope = CompiledScope.CreateRootScope("root", variables);
            var data      = Dynamic(expressionText, rootScope);

            return(data.Evaluate(variables));
        }
Example #3
0
        internal static CompiledTemplate FromBlockNode(string templateName, JinjaEnvironment environment, BlockNode blockNode, IDictionary <string, object?> variableTemplate)
        {
            var rootScope = CompiledScope.CreateRootScope("GLOBALS", variableTemplate);

#if DEBUG
            var expr = NewASTCompiler.ToExpression(templateName, environment, blockNode, out var newcompiler, rootScope);
            return(new CompiledTemplate(environment, ExpressionData.CreateCompiled(expr, rootScope), blockNode.Name, null));
#else
            throw new NotImplementedException();
#endif
        }