Parse() public static method

public static Parse ( HandlebarsParserState state, HandlebarsBlockStack blockStack, SourceLocation location, string expression, IMemberLocator memberLocator = null ) : ExpressionNode
state HandlebarsParserState
blockStack HandlebarsBlockStack
location Veil.Parser.SourceLocation
expression string
memberLocator IMemberLocator
return Veil.Parser.ExpressionNode
Ejemplo n.º 1
0
        public void Should_match_case_insensitivity_correctly(string expression, ExpressionNode expectedResult)
        {
            var scopes = CreateScopes(typeof(CaseTestModel));
            var result = HandlebarsExpressionParser.Parse(scopes, expression);

            result.ShouldDeepEqual(expectedResult);
        }
Ejemplo n.º 2
0
 public void Should_throw_if_expression_cant_be_parsed(string expression)
 {
     Assert.Throws <VeilParserException>(() =>
     {
         HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), expression);
     });
 }
Ejemplo n.º 3
0
        public void Should_be_able_to_reference_parent_scopes_model()
        {
            var current = new { };
            var parent  = new { Name = "" };
            var root    = new { };

            var scopes = CreateScopes(root.GetType(), parent.GetType(), current.GetType());
            var result = HandlebarsExpressionParser.Parse(scopes, "../Name");

            result.ShouldDeepEqual(Expression.Property(parent.GetType(), "Name", ExpressionScope.ModelOfParentScope));
        }
Ejemplo n.º 4
0
        public void Should_parse_field_from_subsubmodel()
        {
            var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "SubModel.SubSubModel.SubSubField");

            result.ShouldDeepEqual(Expression.SubModel(
                                       Expression.Property(typeof(Model), "SubModel"),
                                       Expression.SubModel(
                                           Expression.Field(typeof(SubModel), "SubSubModel"),
                                           Expression.Field(typeof(SubSubModel), "SubSubField"))
                                       )
                                   );
        }
Ejemplo n.º 5
0
        public void Should_parse_as_late_bound_when_model_type_is_not_known <T>(T model)
        {
            var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(T)), "Name");

            result.ShouldDeepEqual(Expression.LateBound("Name", false, ExpressionScope.CurrentModelOnStack));
        }
Ejemplo n.º 6
0
        public void Should_parse_self_expression_node(string expression)
        {
            var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(string)), expression);

            result.ShouldDeepEqual(Expression.Self(typeof(string)));
        }
Ejemplo n.º 7
0
        public void Should_parse_function_from_submodel()
        {
            var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "Function()");

            result.ShouldDeepEqual(Expression.Function(typeof(Model), "Function"));
        }
Ejemplo n.º 8
0
        public void Should_parse_field()
        {
            var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "Field");

            result.ShouldDeepEqual(Expression.Field(typeof(Model), "Field"));
        }
Ejemplo n.º 9
0
        public void Should_parse_property()
        {
            var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "Property");

            result.ShouldDeepEqual(Expression.Property(typeof(Model), "Property"));
        }
Ejemplo n.º 10
0
        public void Should_parse_property_from_submodel()
        {
            var result = HandlebarsExpressionParser.Parse(CreateScopes(typeof(Model)), "SubModel.SubProperty");

            result.ShouldDeepEqual(SyntaxTreeExpression.SubModel(SyntaxTreeExpression.Property(typeof(Model), "SubModel"), SyntaxTreeExpression.Property(typeof(SubModel), "SubProperty")));
        }
Ejemplo n.º 11
0
 public ExpressionNode ParseExpression(string expression, SourceLocation location)
 {
     return(HandlebarsExpressionParser.Parse(this, BlockStack, location, expression, _memberLocator));
 }
Ejemplo n.º 12
0
 public ExpressionNode ParseExpression(string expression)
 {
     return(HandlebarsExpressionParser.Parse(BlockStack, expression));
 }