Ask questionsfor with if example gives js error

I'm trying to do a template with a "for" that has an "if" within it and can't get it to work, gets an error. I found the example on the readme page is very similar and gets the same error.

Example conditional branch from that gives error:

  <title>{{ data.title }}</title>
  <tweets for="data.tweets">
    <section if="data.content">{{ data.content }}</section>

Full code to run:

<script src="mikado.debug.js"></script>
<div id="app"></div>
<template id="tpl">
  <title>{{ data.title }}</title>
  <tweets for="data.tweets">
    <section if="data.content">{{ data.content }}</section>

var data = {
    title: "Some title",
    tweets: [
        {content: "Text1"},
        {content: "Text2"},
        {content: "Text3"},
var view = new Mikado(Mikado.compile('tpl'));

Error is: VM14:3 Uncaught TypeError: Cannot set property 'hidden' of undefined

Code generated:

(function anonymous(p, s, data, index, view) {
    "use strict";
    var self, v;
    if (true) {
        self.hidden = false;                 <----- self was never set, so gets error here
        self = p[1];
        v = data.content;
        if (self._text !== v) {
            self._text = v;
            self.nodeValue = v
        ;self = p[0]
    } else
        self.hidden = true

Mikado 0.7.57


Answer questions sqwishy

Is there a workaround for this?

Edit: For now I have replaced if="test" with if="(self=p[0]) && test" or whatever the "correct" p index is, but I have no idea if this is at all doing the right thing. But I'm curious if this is supposed to do much other than set the "hidden" attribute on the nodes?


Related questions

No questions were found.
Github User Rank List