Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong indentation with t4 templates

I'm currently working with T4 templates and I have noticed that sometimes the code is not indented properly, how can I avoid that?

For instance I have this code in the template

}
    <# } #>
    this.cmbDecisionList.Dat = dataSource;
    this.btnDec.Enabled = dataSource.Count > 0;
}

and in the generated class it's like

}
                 this.cmbDecisionList.Dat = dataSource;
      this.btnDec.Enabled = dataSource.Count > 0;
}
like image 616
John Jerrby Avatar asked Dec 12 '13 08:12

John Jerrby


1 Answers

Allow me to illustrate your problem by replacing spaces with dots.

}
....<# } #>
....this.cmbDecisionList.Dat = dataSource;
    this.btnDec.Enabled = dataSource.Count > 0;
}

and in the generated class it's like

}
........this.cmbDecisionList.Dat = dataSource;
    this.btnDec.Enabled = dataSource.Count > 0;
}

Now, let us remove the preceding dots.

}
<# } #>
....this.cmbDecisionList.Dat = dataSource;
    this.btnDec.Enabled = dataSource.Count > 0;
}

and in the generated class it's like

}
....this.cmbDecisionList.Dat = dataSource;
    this.btnDec.Enabled = dataSource.Count > 0;
}
like image 52
Phillip Scott Givens Avatar answered Sep 27 '22 17:09

Phillip Scott Givens