Exemplo n.º 1
0
        public string Read(Context context, string path)
        {
            var    templateFunc = Context.Compile(path);
            string transformed  = templateFunc(context.Value);

            return(_fileSystemHandler.ReadResponseBodyAsString(transformed));
        }
Exemplo n.º 2
0
        private static string ParseArgumentAndReadFileFragment(IHandlebars handlebarsContext, dynamic context, IFileSystemHandler fileSystemHandler, object[] arguments)
        {
            Check.Condition(arguments, args => args.Length == 1, nameof(arguments));
            Check.NotNull(arguments[0], "arguments[0]");

            switch (arguments[0])
            {
            case string path:
                var    templateFunc = handlebarsContext.Compile(path);
                string transformed  = templateFunc(context);
                return(fileSystemHandler.ReadResponseBodyAsString(transformed));
            }

            throw new NotSupportedException($"The value '{arguments[0]}' with type '{arguments[0]?.GetType()}' cannot be used in Handlebars File.");
        }