jade
jade copied to clipboard
mixins arguments don't include the '$' dollar sign at variable instantiation when outputing std text templates
So, the following mixin, gotten from the tests:
//- Declaration
mixin pet(name)
li.pet= name
//- Use
ul
+pet('cat')
+pet('dog')
+pet('pig')
Converts to this:
<ul>{{ $name := "cat" }}
<li class="pet">{{ name }}</li>
{{ $name := "dog" }}
<li class="pet">{{ name }}</li>
{{ $name := "pig" }}
<li class="pet">{{ name }}</li>
</ul>
But this is not valid text template code, it needs the dollar sign, so it will result in an error.
I expected the following output:
<ul>{{ $name := "cat" }}
<li class="pet">{{ $name }}</li>
{{ $name := "dog" }}
<li class="pet">{{ $name }}</li>
{{ $name := "pig" }}
<li class="pet">{{ $name }}</li>
</ul>
Mmm, maybe these lines: https://github.com/Joker/jade/blob/master/config.go#L33-L34
Shouldn't they be like this:
code__buffered = "{{ $%s }}"
code__unescaped = "{{ $%s }}"
I see that I can change the replace behaviour at runtime, so I can deal with this situation.