canopyclimate/golive

Handle template comments

Closed this issue · 3 comments

Comment tags in templates (e.g. {{/* Blah */}}) breaks rendering. Current assumption is these are added to the Dynamics part of the render tree even though they should never render at all (nor change).

Work around for now is to not have comments in your template. :)

Can you say more? #10 appears to work as antipcated.

The problem is the comment creates an additional Static entry in the tree.

Add the following the line 56 of that test:

if len(lt.Dynamics)+1 != len(lt.Statics) {
	t.Fatal("expected len(lt.Dynamics)+1 to be len(lt.Statics)", len(lt.Dynamics), len(lt.Statics))
}

You'll see that len(lt.Dynamics) is 1 while len(lt.Statics) is 3.

It is the case that len(Dynamics) should always be len(Statics)-1.

Because of the extra Statics when the tree is rendered on the client an additional undefined is added to the DOM for each additional Static.

Maybe we can track when sequential AppendStatics are called without an intermediate AppendDynamic and simply concatenate those together?

Thanks, that makes sense now.

Maybe we can track when sequential AppendStatics are called without an intermediate AppendDynamic and simply concatenate those together?

This sounds like the right approach.