Did you know ... Search Documentation:
Pack canny_tudor -- prolog/canny/placeholders.pl
PublicShow source

This module provides predicates for formatting strings with placeholders. Placeholders are specified in the form of {name} within a format string. The placeholders are replaced with corresponding values from a list of options, where each option is specified as name(Value). The result is an atom containing the formatted string. The module uses DCG rules to parse the format string and replace the placeholders with the corresponding values.

The main predicate is format_placeholders/3, which takes a format string, an atom to hold the result, and a list of options. It processes the format string, replacing placeholders with their corresponding values from the options list. If a placeholder does not have a corresponding value, it will fail.

The format_placeholders/3 predicate formats a string with placeholders, while format_placeholders/4 allows for additional options to be returned; namely, the remaining options after processing the placeholders.

author
- Roy Ratcliffe
version
- 0.1.0
 format_placeholders(+Format, -Atom, +Options) is det
 format_placeholders(+Format, -Atom, +Options, -RestOptions) is det
Formats a string with placeholders in the form of {name}. The placeholders are replaced with corresponding values from the options list. The result is an atom with the formatted string.

The Format string can be any atom or string containing placeholders. The Options list should contain terms of the form name(Value), where name is the placeholder name and Value is the value to replace it with. If a placeholder does not have a corresponding value in the Options list, it will not be replaced, and the placeholder will remain in the resulting atom.

Arguments:
Format- The format string containing placeholders.
Atom- The resulting atom with placeholders replaced.
Options- The list of options containing values for placeholders.
RestOptions- The remaining options after processing the placeholders.
 placeholders(-Terms, ?Options)// is det
Formats a list of terms by replacing placeholders in the form of {name} with corresponding values from the options list. The placeholders are replaced with the values associated with the names in the options list.

The result is a list of atoms and values, and a completed options list.

Arguments:
Terms- The list of terms to be formatted.
Options- The list of options containing values for placeholders.
 placeholders(+Terms0, -Terms, +Options0, -Options)// is det
Processes a format string with placeholders using a list of terms and options. The format string is the difference list of codes, where placeholders are replaced with values from the options list. The result is a list of atomics and an updated options list.

Scans the input, replacing placeholders of the form {name} with values from the options list. The result is a list of atoms and values, and an updated options list. Uses DCG rules for flexible parsing and substitution.

The resulting list of terms contains atoms and values, where each placeholder is replaced with the corresponding value from the options list. The options list is updated to include any new options found in the format string.

Unifies the same placeholder with the same value in the options list if it appears more than once. Placeholders can appear in the format string multiple times, and each occurrence will be replaced with the same value.

Arguments:
Terms0- The initial list of terms to be processed.
Terms- The resulting list of terms after processing.
Options0- The initial list of options to be processed.
Options- The resulting list of options after processing.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 format_placeholders(Arg1, Arg2, Arg3, Arg4)