Did you know ... | Search Documentation: |
![]() | Pack canny_tudor -- prolog/canny/placeholders.pl |
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.
{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.
{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.
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.
The following predicates are exported, but not or incorrectly documented.