himl icon indicating copy to clipboard operation
himl copied to clipboard

Nested interpolation lost when mixed inside string context

Open aniongithub opened this issue 7 months ago • 3 comments

Summary When using Himl’s (himl==0.15.2 from pip) nested interpolation ({{foo.bar}}) inside a longer string, the interpolation silences the surrounding text and resolves only to the raw value. But when using the same interpolation alone, it works correctly.


Steps to reproduce

  1. Create foo.yaml:

    foo:
      bar: 42
    
  2. Create baz.yaml:

    resources:
      test:
        type: example:Test
        properties:
          path: "hello {{foo.bar}} world"
    
  3. Run:

    himl-config-merger foo.yaml baz.yaml > merged.yaml
    
  4. Expected in merged.yaml:

    resources:
      test:
        properties:
          path: "hello 42 world"
    
  5. Actual result:

    resources:
      test:
        properties:
          path: 42
    

    — The string collapses to just 42.

  6. Alternative case that does work:

    path: "{{foo.bar}}"
    

    → Correctly interpolates to:

    path: 42
    

Any help would be much appreciated!

aniongithub avatar Jun 25 '25 05:06 aniongithub

It appears the bug is here

If the value to interpolate is anything other than a string, it simply returns the value itself instead of doing line.replace

aniongithub avatar Jun 25 '25 05:06 aniongithub

Thanks for reporting this issue! Would you also file a PR please?

amuraru avatar Sep 14 '25 21:09 amuraru

Can do, I have a fork with this already, will clean and submit. Thanks!

aniongithub avatar Sep 18 '25 05:09 aniongithub