Skip to content

How to output a list of arrays #1

@thomasd

Description

@thomasd

Hello, thank you for work on SmartFormat it is exactly what I was searching for my project.

Now I try to output a list of arrays of floats and get the value of the items in the array per index:
example:

 {Object.ListOfArrays:{0} = first Item in Array, {1} = second Item in Array|; }

This is the data in C# notation:

var Object = new {
    ListOfArrays = new List()
    {
        {1,2},
        {1.4,4.12}
    }
};

And how I call Smart.Format:

Smart.Format(
    "{Object.ListOfArrays:{0} = first Item in Array, {1} = second Item in Array|; }",
    new{
        Object=Object
    });

My expected output is:

1 = first Item in Array, 2 = second Item in Array; 1.4 = first Item in Array, 4.12 = second Item in Array

But instead of getting the items in the arrays back, SmartFormat outputs the first parameter on {0} and nothing on {1} as there is no second parameter. And I perfectly understand why this happens as {0} refers to the first parameter on Smart.Format.
But my question is: Is there any way to access the elements of the arrays per index? Or is this type of nested templates only possible with named selectors like in your examples?

I hope it is understandable what my problem is and maybe someone can help me with this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions