Path() 공개 정적인 메소드

public static Path ( string path ) : HandlebarsDotNet.Compiler.PathExpression
path string
리턴 HandlebarsDotNet.Compiler.PathExpression
        protected override Expression VisitDeferredSectionExpression(DeferredSectionExpression dsex)
        {
            var method = new Action <object, BindingContext, Action <TextWriter, object>, Action <TextWriter, object> >(RenderSection).Method;

            Expression path    = HandlebarsExpression.Path(dsex.Path.Path.Substring(1));
            Expression context = CompilationContext.BindingContext;

            Expression[] templates = GetDeferredSectionTemplates(dsex);

            return(Expression.Call(method, new[] { path, context }.Concat(templates)));
        }
예제 #2
0
 public override IEnumerable <object> ConvertTokens(IEnumerable <object> sequence)
 {
     foreach (var item in sequence)
     {
         if (item is WordExpressionToken wordExpressionToken)
         {
             yield return(HandlebarsExpression.Path(wordExpressionToken.Value));
         }
         else
         {
             yield return(item);
         }
     }
 }
예제 #3
0
        protected override Expression VisitDeferredSectionExpression(DeferredSectionExpression dsex)
        {
            Action <object, BindingContext, Action <TextWriter, object> > method;

            if (dsex.Path.Path.StartsWith("#"))
            {
                method = RenderSection;
            }
            else if (dsex.Path.Path.StartsWith("^"))
            {
                method = RenderEmptySection;
            }
            else
            {
                throw new HandlebarsCompilerException("Tried to compile a section expression that did not begin with # or ^");
            }
            return(Expression.Call(
                       method.Method,
                       HandlebarsExpression.Path(dsex.Path.Path.Substring(1)),
                       CompilationContext.BindingContext,
                       new FunctionBuilder(CompilationContext.Configuration).Compile(dsex.Body, CompilationContext.BindingContext)));
        }
예제 #4
0
        private static object ParseValue(string value)
        {
            if (value.StartsWith("'") || value.StartsWith("\""))
            {
                return(value.Trim('\'', '"'));
            }

            bool boolValue;

            if (bool.TryParse(value, out boolValue))
            {
                return(boolValue);
            }

            int intValue;

            if (int.TryParse(value, out intValue))
            {
                return(intValue);
            }

            return(HandlebarsExpression.Path(value));
        }