mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
docs: Add section on referencing templates
This commit is contained in:
parent
8a6ad847b6
commit
71a43a4a86
1 changed files with 15 additions and 2 deletions
|
@ -66,14 +66,27 @@ This ``MapsHeaderBar`` class, along with its blueprint template, can then be ref
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID & Parent Parameters
|
Type & Parent Parameters
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
The type name that directly follows the ``template`` keyword is the type of the template class. In most cases, this will be an extern type starting with ``$`` and matching the class name in the application code. Templates for use in a `Gtk.BuilderListItemFactory <https://docs.gtk.org/gtk4/class.BuilderListItemFactory.html>`_ use ``ListItem`` as the type name instead.
|
The type name that directly follows the ``template`` keyword is the type of the template class. In most cases, this will be an extern type starting with ``$`` and matching the class name in the application code. Templates for use in a `Gtk.BuilderListItemFactory <https://docs.gtk.org/gtk4/class.BuilderListItemFactory.html>`_ use ``ListItem`` as the type name instead.
|
||||||
|
|
||||||
The parent type is optional, and may only be present if the template type is extern. It enables limited type checking for the properties and signals of the template object.
|
The parent type is optional, and may only be present if the template type is extern. It enables limited type checking for the properties and signals of the template object.
|
||||||
|
|
||||||
|
|
||||||
|
Referencing a Template
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
To reference the template object in a binding or expression, use the ``template`` keyword:
|
||||||
|
|
||||||
|
.. code-block:: blueprint
|
||||||
|
|
||||||
|
template $MyTemplate {
|
||||||
|
prop1: "Hello, world!";
|
||||||
|
prop2: bind template.prop1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Language Implementations
|
Language Implementations
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue