1#!/usr/bin/env python3
2
3import gi
4
5gi.require_version('Template', '1.0')
6
7from gi.repository import Gio
8from gi.repository import Template
9
10# Get our file to process
11file = Gio.File.new_for_path('simple.tmpl')
12
13# Create a new template and parse our input file
14tmpl = Template.Template()
15tmpl.parse_file(file, None)
16
17# Create scope for expansion
18scope = Template.Scope.new()
19
20# Create and assign "title" variable in scope
21title = scope.get('title')
22title.assign_string('Example Title')
23
24# Expand the template into stream
25expanded = tmpl.expand_string(scope)
26print(expanded)
27