i-love-flamingo / pugtemplate

A Pug Template engine for Flamingo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

False boolean in attribute overwrites values

d-p-dev opened this issue · comments

commented

We discovered that falsy booleans are interpreted quite weirdly by the compiler. When writing something like the following:

- var classVariable = false
.className(class=classVariable)

One could expect to keep the className class in the rendered HTML afterwards, indeed there are snippets of code that intend to do that (runtime.go line 149 to 155). But in effect this div won't receive any classes.

is:
<div></div>
instead of:
<div class="className"></div>

Because of all the reflections in this place I couldn't really find what was going on.

First of all what is the behaviour should we expect for attributes with values that are either false or null? If the expected behaviour I described above is the correct one, what would be the best way to keep track of the various ways of attaching attributes or to have falsy booleans not be reflected as "no attribute" in HTML?