Skip to content

Issues with conditional attributes #70

@honux

Description

@honux

Bug 1:
Whenever there are no default classes being included on a tag and all the included classes are with conditional values, the template is not rendered according to the expectations.

Reproduction guide:
Run the following template:

$var_1 = 20
div
    .foo ? $var_1 == 10
    .bar ? $var_1 == 20

Compiled template:

{{$var_1 := 20}}{{$__amber_1 := __amber_eql $var_1 10}}{{$__amber_2 := __amber_eql $var_1 20}}
<div{{if $__amber_1}} class="{{if $__amber_1}}foo{{end}} {{if $__amber_2}}bar{{end}}"{{end}}></div>

Expected result:

<div class="bar"></div>

Real result:

<div></div>

Bug 2:
Whenever adding attributes to a tag, if the same attribute appears multiple times with different conditions, just the latest one is considered.

Reproduction guide:
Run the following template:

$var_1 = 10
div
    [foo="bar"] ? $var_1 == 10
    [foo="zaz"] ? $var_1 == 20

Compiled template:

{{$var_1 := 20}}{{$__amber_1 := __amber_eql $var_1 10}}{{$__amber_2 := __amber_eql $var_1 20}}
<div{{if $__amber_2}} foo="zaz"{{end}}></div>

Expected result:

<div foo="bar"></div>

Real result:

<div></div>

Version: Latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions