libucl icon indicating copy to clipboard operation
libucl copied to clipboard

Feature request: A parser flag to expand variables inside marco options.

Open Crest opened this issue 1 year ago • 1 comments

I would like to use something along this line in my configuration. While I could manually expand $base_dir and $local_dir having to expand $name would require using an external template engine.

.include(
    path: [
        "${base_dir}/hooks/"
        "${local_dir}/hooks/"
        "${base_dir}/${name}/hooks/"
        "${local_dir}/${name}/hooks/"
    ]) "*.conf"

The problem I encountered is that the UCL parser creates a new temporary parser to parse the macro options into a UCL object passed to the registered macro callback. The temporary parser created on behalf of the macro doesn't inherit anything registered with the outer parser (variables, macros, undefined variable handlers, etc.). My preferred solution to this would be a new parser option to have the outer parser register anything registered with it with the temporary parser before having it parse the macro options unless there is a better way I missed.

Crest avatar Apr 06 '23 14:04 Crest

Should the title be "macro variables"?

michaeldexter avatar Apr 12 '23 23:04 michaeldexter