Skip to content

Wrong indentation when rendering nested templates #136

@mottzi

Description

@mottzi

Describe the issue

When a template is rendered that extends a child template using #extend, all but the first line of the child template will have wrong indentation.

Vapor version

4

Operating system and version

Ubuntu 22.04

Swift version

6

Steps to reproduce

Parent template:

<!DOCTYPE html>
<html>
<head>
    <style>
        th, td { padding: 0 15px; }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr>
                <th>Component ID</th>
                <th>DummyModel1</th>
                <th>DummyModel2</th>
            </tr>
        </thead>
        <tbody>
        #for(component in components):
            #extend("DummyComponent")
        #endfor
        </tbody>
    </table>

    <script src="/mist.js"></script>
</body>
</html>

Child template:

<tr mist-component="DummyComponent" mist-id="#(component.dummymodel1.id)">
    <td>#(component.dummymodel1.id)</td>
    <td>#(component.dummymodel1.text)</td>
    <td>#(component.dummymodel2.text2)</td>
</tr>

Outcome

Rendered parent template:

<!DOCTYPE html>
<html>
<head>
    <style>
        th, td { padding: 0 15px; }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr>
                <th>Component ID</th>
                <th>DummyModel1</th>
                <th>DummyModel2</th>
            </tr>
        </thead>
        <tbody>
        
            <tr mist-component="DummyComponent" mist-id="9758DFBB-2687-4089-AEB5-D839DB620DB6">
    <td>9758DFBB-2687-4089-AEB5-D839DB620DB6</td>
    <td>leaf</td>
    <td>client</td>
</tr>
   
        </tbody>
    </table>

    <script src="/mist.js"></script>
</body>
</html>

This:

            <tr mist-component="DummyComponent" mist-id="9758DFBB-2687-4089-AEB5-D839DB620DB6">
    <td>9758DFBB-2687-4089-AEB5-D839DB620DB6</td>
    <td>leaf</td>
    <td>client</td>
</tr>

should be:

            <tr mist-component="DummyComponent" mist-id="9758DFBB-2687-4089-AEB5-D839DB620DB6">
                <td>9758DFBB-2687-4089-AEB5-D839DB620DB6</td>
                <td>leaf</td>
                <td>client</td>
            </tr>

Additional notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions