Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Render Fixed Length String? #798

Open
KiddoV opened this issue Apr 20, 2022 · 0 comments
Open

How to Render Fixed Length String? #798

KiddoV opened this issue Apr 20, 2022 · 0 comments

Comments

@KiddoV
Copy link

KiddoV commented Apr 20, 2022

Suppose I have a template:

[PartList]
RefID.            P/N                                       XPos        YPos       Rtn       Pkg                                       Extension
{{#data}}
{{refID}}         {{partNumber}}                            {{xPos}}    {{yPos}}   {{rotn}}  {{packageName}}                           ----
{{/data}}
[PartListEnd]

In JS:

var output = Mustache.render(templateAbove, {
    data: [{
        refID: "A1",
        partNumber: "12345678L",
        xPos: "1080.00",
        yPos: "80.00",
        rotn: 90,
        packageName: "TEST_PKG"
    }, {
        refID: "A10",
        partNumber: "12345678L",
        xPos: "1080.00",
        yPos: "80.00",
        rotn: 90,
        packageName: "TEST_PKG"
    }]
});

Right now it would render:

[PartList]
RefID.            P/N                                       XPos        YPos       Rtn       Pkg                                       Extension
A1         12345678L                            1080.00    80.00   90  TEST_PKG                           ----
A10         12345678L                            1080.00    80.00   90  TEST_PKG                           ----
[PartListEnd]

How do I make it align in columns like this?

[PartList]
RefID.            P/N                                       XPos        YPos       Rtn       Pkg                                       Extension
A1                12345678L                                 1080.00     80.00      90        TEST_PKG                                  ----
A10               12345678L                                 1080.00     80.00      90        TEST_PKG                                  ----
[PartListEnd]

In other words, how do I make each value in the object display as a fixed length string?
Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@KiddoV and others