Then, in my HAML template (source/test.haml), I can print relative path to pageA with = data.pages.pageA.link.

Now, I want to use markdown syntax to reference that page by its name (pageA).

Example (source/test.haml):

.info
:markdown
This is some text with a [manual link](https://google.com) to somewhere.
This is another text with a [data-referenced link](pageA) to that page.

In the same way as first "manual link" links to Google, I would like second link to use relative path stored in data file to create a link. One solution that I see to solve this problem would be to replace (pageA) text with evaluation of = data.pages.pageA.link prior to it being rendered by markdown.

I assume this would be possible by creating custom helper, but I can't quite nail it.

Ps. I now posted my attempted solution in a reply with primitive substitution and explained how it didn't work for me.

My attempt at solution

I tried to write a custom helper to replace (pageA) text with evaluation of = data.pages.pageA.link prior to it being rendered by markdown.

I was able to replace specific text (pageA) with information from data and I was also able to write more generic case, which replaces all data references with explicit text of typical data reference. But I can't get to replace data.pages.pageA.link in generic case for evaluation of = data.pages.pageA.link.

The solution is to use ERB code instead for pageA reference together with html.haml.erb template extension and then everything happens automatically without need for any custom helper. Details are here.