Getting started - Athari/Alba.Jaml GitHub Wiki
!!!WARNING!!! This library is a proof-of-concept and as such not intended to be used in real projects. You're welcome to experiment, but please don't fret if something doesn't work.
- Add
Alba.Jaml
project to your solution. - Add
Json.NET
reference (you can use Json.NET NuGet package). - To automatically regenerate XAML file when JAML file is changed, install T4 Toolbox.
- To get some syntax highlighting in Visual Studio, open Tools > Options > Text Editor > File Extension, enter
jaml
into Extension field, choose Script Editor in Editor drop-down, and click Apply. - Build
Alba.Jaml
project. - Create
Jaml.ttinclude
in your project with the following code (you may need to change paths to assemblies):
<#@ template hostspecific="true" debug="true" #><#@ output extension="g.xaml"
#><#@ assembly name="$(SolutionDir)\Alba.Jaml\bin\Debug\Newtonsoft.Json.dll"
#><#@ assembly name="$(SolutionDir)\Alba.Jaml\bin\Debug\Alba.Jaml.dll"
#><#@ include file="$(SolutionDir)\Alba.Jaml\T4\Jaml.ttinclude"
#>
- Create a new text file with
jaml
extension, its name will become class name. You can use code from Example 1: Simple window as a strating point. - Set
Custom Tool
option on theProperties
page of the JAML file toT4ScriptFileGenerator
. A new TT sub-file will be created. Replace its contents with the following code (you may need to change path toJaml.ttinclude
if it's not in the same directory as JAML file):
<#@ include file="Jaml.ttinclude" #><# GenerateJaml(); #>
- Three new sub-files will be created:
[FileName].g.xaml
- generated XAML, will be regenerated when JAML is saved[FileName].g.xaml.cs
- generated CS with converters, will be regenerated when JAML is saved[FileName].xaml.cs
- user code-behind
Now you can write code in your JAML file. When you need to create new JAML files, you need to repeat only steps 7 and 8.