+
Skip to content

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

@zkamvar

Description

@zkamvar

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载