Allow GET requests #13

Closed
opened 2020-12-28 20:34:43 +00:00 by jolheiser · 2 comments
jolheiser commented 2020-12-28 20:34:43 +00:00 (Migrated from gitea.com)

Consider adding GET requests to the spec, where a user would be prompted (in case they don't want to/can't use internet) to allow tmpl to use a pre-defined request (using any relevant values) to fill out a template.

To expand the project FAQ

# The "key" is enclosed in braces
[author]
# prompt is what will be shown to prompt the user
prompt = "The name of the author of this project"
# help would be extra information (generally seen by giving '?' to a prompt)
help = "Who will be primarily writing this project"
# default is the "value" part of the simple pair. This could be a suggested value
default = "$USER"
# url is a GET request that a user must confirm that can be used to get data
# if the request is not confirmed, fall back to default
url = "https://randomuser.me/api/?noinfo&results=1&seed=$SEED"

In the above, due to how randomuser returns results, the object could be used in a template via {{(index author.results 0).login.username}}
The template would need to tell users to set $SEED if they want consistent results (in this example scenario)

Consider adding GET requests to the spec, where a user would be prompted (in case they don't want to/can't use internet) to allow `tmpl` to use a pre-defined request (using any relevant values) to fill out a template. To expand the project FAQ ```toml # The "key" is enclosed in braces [author] # prompt is what will be shown to prompt the user prompt = "The name of the author of this project" # help would be extra information (generally seen by giving '?' to a prompt) help = "Who will be primarily writing this project" # default is the "value" part of the simple pair. This could be a suggested value default = "$USER" # url is a GET request that a user must confirm that can be used to get data # if the request is not confirmed, fall back to default url = "https://randomuser.me/api/?noinfo&results=1&seed=$SEED" ``` In the above, due to how randomuser returns results, the object could be used in a template via `{{(index author.results 0).login.username}}` The template would need to tell users to set `$SEED` if they want consistent results (in this example scenario)
jolheiser commented 2020-12-28 20:36:54 +00:00 (Migrated from gitea.com)

As part of the above example (and for wider adaptability), introduce helpers json, yaml, and toml to decode text.

The above would then become {{(index (json author).results 0).login.username}}

As part of the above example (and for wider adaptability), introduce helpers `json`, `yaml`, and `toml` to decode text. The above would then become `{{(index (json author).results 0).login.username}}`
jolheiser commented 2020-12-28 23:13:11 +00:00 (Migrated from gitea.com)

New idea, detailed below. url types would be called after prompt types, allowing creators to use prompt answers in the URLs.

# The "key" is enclosed in braces
[author]
# type is the type of key, either "prompt" (default) or "url"
type = "url"
# url is a GET request that a user must confirm that can be used to get data
# if the request is not confirmed, fall back to default
url = "https://randomuser.me/api/?noinfo&results=1&seed={{seed}}"
# format allows you to decode the response if necessary
# text, json, yaml, toml
format = "json"

[seed]
prompt = "What seed to use for the random user?"
help = "Set to a known value for consistent responses"
default = "$USER"
New idea, detailed below. `url` types would be called after `prompt` types, allowing creators to use prompt answers in the URLs. ```toml # The "key" is enclosed in braces [author] # type is the type of key, either "prompt" (default) or "url" type = "url" # url is a GET request that a user must confirm that can be used to get data # if the request is not confirmed, fall back to default url = "https://randomuser.me/api/?noinfo&results=1&seed={{seed}}" # format allows you to decode the response if necessary # text, json, yaml, toml format = "json" [seed] prompt = "What seed to use for the random user?" help = "Set to a known value for consistent responses" default = "$USER" ```
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jolheiser/tmpl#13
There is no content yet.