Skip to content

Commit db7f044

Browse files
authored
fix(template): expandable variables in lua expr (#841)
This fixes the order which the template is compiled. Previously, the expressions %() were compiled before expandable variables (such as %x). This made the example template in [1] to produce: * [[url][x]] instead of * [[url][end part of the url]] By doing the expression compilation after expandable ones, this issue is resolved. [1] https://github.com/nvim-orgmode/orgmode/wiki/Getting-Started#captures
1 parent 07c479c commit db7f044

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lua/orgmode/capture/template/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ end
250250
---@return OrgPromise<string | nil>
251251
function Template:_compile(content, content_type)
252252
content = self:_compile_dates(content)
253-
content = self:_compile_expressions(content)
254253
if self._compile_hooks then
255254
for _, hook in ipairs(self._compile_hooks) do
256255
content = hook(content, content_type) --[[@as string]]
@@ -267,6 +266,7 @@ function Template:_compile(content, content_type)
267266
if not cnt then
268267
return nil
269268
end
269+
cnt = self:_compile_expressions(cnt)
270270
return self:_compile_prompts(cnt)
271271
end)
272272
end)

0 commit comments

Comments
 (0)