Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: function to return data frame of keys in template #33

Open
zkamvar opened this issue Sep 10, 2020 · 0 comments
Open

Feature request: function to return data frame of keys in template #33

zkamvar opened this issue Sep 10, 2020 · 0 comments

Comments

@zkamvar
Copy link

zkamvar commented Sep 10, 2020

It would be nice to have a function that generates a data frame of keys for a given template for programmatic generation of input data. I'm thinking something along the lines of:

template <- 
    "{{#dat}}
    count: {{count}}, spray: {{spray}}\n
    {{/dat}}" 
whisker::getKeys(template)
#>   rawkey first last   key type
#> 1   #dat     1    8   dat    #
#> 2  count    20   28 count     
#> 3  spray    38   46 spray     
#> 4   /dat    49   56   dat    /

FWIW, the functionality in {whisker} already exists, it just needs to be exposed:

template <- 
    "{{#dat}}
    count: {{count}}, spray: {{spray}}\n
    {{/dat}}" 

f <- whisker:::parseTemplate(template)
get("key", envir = environment(f))
#>   rawkey first last   key type
#> 1   #dat     1    8   dat    #
#> 2  count    20   28 count     
#> 3  spray    38   46 spray     
#> 4   /dat    49   56   dat    /

Created on 2020-09-10 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant