Getting started - Athari/Alba.Jaml 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.

  1. Add Alba.Jaml project to your solution.
  2. Add Json.NET reference (you can use Json.NET NuGet package).
  3. To automatically regenerate XAML file when JAML file is changed, install T4 Toolbox.
  4. 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.
  5. Build Alba.Jaml project.
  6. 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"
#>
  1. 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.
  2. Set Custom Tool option on the Properties page of the JAML file to T4ScriptFileGenerator. A new TT sub-file will be created. Replace its contents with the following code (you may need to change path to Jaml.ttinclude if it's not in the same directory as JAML file):
<#@ include file="Jaml.ttinclude" #><# GenerateJaml(); #>
  1. 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.