diff options
| author | Albert Krewinkel <[email protected]> | 2022-10-11 21:40:21 +0200 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-10-11 14:03:08 -0700 |
| commit | 78d7fc46febe3f2d5ebc1bea4761d115bb26f117 (patch) | |
| tree | ffb4bccbdc58ee339cfdd44879b8fb153f4dc3a1 /pandoc-lua-engine/test/lua/module | |
| parent | 3cac33bdd2b2b69ac585cc37498deea49763c665 (diff) | |
Lua: add function `pandoc.template.apply`
The new function applies a context, containing variable assignments, to
a template.
Diffstat (limited to 'pandoc-lua-engine/test/lua/module')
| -rw-r--r-- | pandoc-lua-engine/test/lua/module/pandoc-template.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pandoc-lua-engine/test/lua/module/pandoc-template.lua b/pandoc-lua-engine/test/lua/module/pandoc-template.lua index 5b31e5ae0..bda24da65 100644 --- a/pandoc-lua-engine/test/lua/module/pandoc-template.lua +++ b/pandoc-lua-engine/test/lua/module/pandoc-template.lua @@ -62,4 +62,24 @@ return { ) end), }, + group 'apply' { + test('is function', function () + assert.are_equal(type(template.apply), 'function') + end), + test('returns a Doc value', function () + local tmpl = template.compile('placeholder') + assert.are_equal( + pandoc.utils.type(template.apply(tmpl, {})), + 'Doc' + ) + end), + test('applies the given context', function () + local tmpl = template.compile('song: $title$') + local context = {title = 'Along Comes Mary'} + assert.are_equal( + template.apply(tmpl, context):render(), + 'song: Along Comes Mary' + ) + end), + }, } |
