texttemplate

Provides support for text template files. More...

Since: Qbs 1.13

Properties

Detailed Description

The texttemplate module provides support for text template files.

Example

Consider the following text file greeting.txt.in.

${greeting} ${name}!

This can be used in a project like this:

Product {
    type: ["text"]
    files: ["greeting.txt.in"]
    Depends { name: "texttemplate" }
    texttemplate.dict: ({
            greeting: "Hello",
            name: "World"
        })
}

Which will create the file greeting.txt.

Hello World!

The same result can be achieved using the alternative placeholder format:

Product {
    type: ["text"]
    files: ["greeting.txt.in"]
    Depends { name: "texttemplate" }
    texttemplate.placeholder: "@@"
    texttemplate.dict: ({
            greeting: "Hello",
            name: "World"
        })
}

Where greeting.txt.in contains:

@greeting@ @name@!

Placeholder Syntax

The texttemplate module supports two placeholder formats, controlled by the placeholder property.

A placeholder ${foo} is replaced by its corresponding value in texttemplate.dict. Placeholder names consist of alphanumeric characters only.

The placeholder ${$} is always replaced with $. If you need a literal ${foo} in your template, use ${$}{foo}.

When texttemplate.placeholder is set to "@@", placeholders use the format @foo@ instead.

Placeholders that are not defined in the dictionary will produce an error.

Relevant File Tags

TagAuto-tagged File NamesSinceDescription
"texttemplate.input"*.in1.13.0Source files with this tag serve as inputs for the text template rule.

Property Documentation

dict : var

The dictionary containing values for all keys used in the template file.

Default: {}


outputFileName : string

The output file name that is assigned to produced artifacts.

Default: Complete base name of the input file


outputTag : string

The output tag that is assigned to produced artifacts.

Default: "text"


[since Qbs 3.1] placeholder : string

The placeholder format to use for text template files.

Possible values: "${}", "@@"

Default: "${}"

This property was introduced in Qbs 3.1.


© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.