TmplTemplate: Template-GLib Reference Manual

## TmplTemplate TmplTemplate |

## Functions

TmplTemplate * | tmpl_template_new ()
TmplTemplateLocator * | tmpl_template_get_locator ()
void | tmpl_template_set_locator ()
gboolean | tmpl_template_parse_file ()
gboolean | tmpl_template_parse_resource ()
gboolean | tmpl_template_parse_path ()
gboolean | tmpl_template_parse_string ()
gboolean | tmpl_template_parse ()
gboolean | tmpl_template_expand ()
gchar * | tmpl_template_expand_string ()

## Properties

TmplTemplateLocator * | locator | Read / Write / Construct

## Types and Values

#define | TMPL_TYPE_TEMPLATE
struct | TmplTemplateClass
| TmplTemplate

## Object Hierarchy

        GObject
        ╰── TmplTemplate

## Description

## Functions

### tmpl_template_new ()

    TmplTemplate *
    tmpl_template_new (TmplTemplateLocator *locator);

Creates a new TmplTemplate.

If `locator` is specified, `locator` will be used to resolve include directives when parsing the template.

#### Parameters

locator | A TmplTemplateLocator or `NULL`. | [nullable]

#### Returns

A TmplTemplate.

[transfer full]

### tmpl_template_get_locator ()

    TmplTemplateLocator *
    tmpl_template_get_locator (TmplTemplate *self);

Gets the template locator used when resolving template includes.

#### Parameters

self | A TmplTemplate |

#### Returns

a TmplTemplateLocator or `NULL`.

[transfer none]

### tmpl_template_set_locator ()

    void
    tmpl_template_set_locator (TmplTemplate *self,
                               TmplTemplateLocator *locator);

### tmpl_template_parse_file ()

    gboolean
    tmpl_template_parse_file (TmplTemplate *self,
                              GFile *file,
                              GCancellable *cancellable,
                              GError **error);

### tmpl_template_parse_resource ()

    gboolean
    tmpl_template_parse_resource (TmplTemplate *self,
                                  const gchar *path,
                                  GCancellable *cancellable,
                                  GError **error);

### tmpl_template_parse_path ()

    gboolean
    tmpl_template_parse_path (TmplTemplate *self,
                              const gchar *path,
                              GCancellable *cancellable,
                              GError **error);

### tmpl_template_parse_string ()

    gboolean
    tmpl_template_parse_string (TmplTemplate *self,
                                const gchar *input,
                                GError **error);

### tmpl_template_parse ()

    gboolean
    tmpl_template_parse (TmplTemplate *self,
                         GInputStream *stream,
                         GCancellable *cancellable,
                         GError **error);

### tmpl_template_expand ()

    gboolean
    tmpl_template_expand (TmplTemplate *self,
                          GOutputStream *stream,
                          TmplScope *scope,
                          GCancellable *cancellable,
                          GError **error);

Expands a template into `stream` using the `scope` provided.

`scope` should have all of the variables set that are required to expand the template, or you will get a symbol reference error and `FALSE` will be returned.

To set a symbol value, get the symbol with `tmpl_scope_get()` and assign a value using `tmpl_scope_assign_value()` or similar methods.

#### Parameters

self | A TmplTemplate. |
stream | a GOutputStream to write the results to |
scope | A TmplScope containing state for the template, or `NULL`. | [nullable]
cancellable | An optional cancellable for the operation. | [nullable]
error | A location for a GError, or `NULL`. |

#### Returns

`TRUE` if successful, otherwise `FALSE` and `error` is set.

### tmpl_template_expand_string ()

    gchar *
    tmpl_template_expand_string (TmplTemplate *self,
                                 TmplScope *scope,
                                 GError **error);

Expands the template and returns the result as a string.

#### Parameters

self | A TmplTemplate. |
scope | A TmplScope or `NULL`. | [nullable]
error | A location for a GError, or `NULL` |

#### Returns

A newly allocated string, or `NULL` upon failure.

## Types and Values

### TMPL_TYPE_TEMPLATE

    #define TMPL_TYPE_TEMPLATE (tmpl_template_get_type())

### struct TmplTemplateClass

    struct TmplTemplateClass {
      GObjectClass parent_class;
    };

### TmplTemplate

    typedef struct _TmplTemplate TmplTemplate;

## Property Details

### The `“locator”` property

      “locator”                  TmplTemplateLocator *

The locator used for resolving includes.

Flags: Read / Write / Construct