Skip to main content

Global Directive in Biml

What the Global Directive Does

The global directive adds a Biml file's contents to other Biml files automatically. A two line global file is enough to set Visual Basic as the default template language across an entire solution.

<#@ global #>
<#@ template language="VB" #>

A different global file can prepend a comment to every Biml file in the project.

<#@ global #>
<!-- Global Header -->

Both effects can live in a single file. There is no rule that forces one global concern per file.

Optional Parameters

The directive accepts up to four parameters, all optional. The two examples above are equivalent to the explicit form below.

<#@ global active="True" location="top" order="0" scope="Global" #>
<#@ template language="VB" #>
<!-- Global Header -->

The parameters are:

  1. active. A boolean that toggles the global file on or off without removing it.
  2. location. Either top or bottom. Controls whether the global content is prepended or appended to each target file.
  3. order. When several global files apply, the order parameter sets the sequence in which they are merged.
  4. scope. Controls which Biml files the global applies to. The supported values include:
    • Global. Applies to every file.
    • Folder or FolderRecursive. Applies only to files in the same folder, or that folder plus its subfolders.
    • LogicalDisplayFolder or LogicalDisplayFolderRecursive. Same as Folder, but for logical folders rather than physical ones.
    • Bundle, BundleExtension, or NonBundle. Used when working with bundles.

A fifth attribute, applytocallbimlscript, is also a boolean and defaults to True. It controls whether the global file is also injected into files invoked through CallBimlScript.

Why It Matters

Global directives keep cross cutting concerns out of every individual Biml file. Default template languages, shared namespaces, common include directives, project wide variable declarations, and house style headers all become single edits in a single file rather than copy and paste tasks across the solution.

The Folder and LogicalDisplayFolder scopes are particularly useful in BimlStudio, where folder organization carries semantic meaning and a global file can target a specific subset of a larger solution without affecting the rest.