MommaWatasu / OteraEngine.jl

This package is a template engine for Julia Lang.
https://mommawatasu.github.io/OteraEngine.jl/stable
MIT License
20 stars 4 forks source link

(::Template)(; init) got unsupported keyword argument "tmp_init" #30

Closed codigomaye closed 6 months ago

codigomaye commented 6 months ago

Hello Dear @MommaWatasu, how are you?

Thank you for your hard work on OteraEngine. I tried it, but I ran into this issue:

The Problem

Following the example in https://mommawatasu.github.io/OteraEngine.jl/dev/tutorial/#Main.OteraEngine.Template, I get the following error.

ERROR: MethodError: no method matching (::Template)(; tmp_init::Dict{String, String})

Closest candidates are:
  (::Template)(; init) got unsupported keyword argument "tmp_init"
   @ OteraEngine ~/.julia/packages/OteraEngine/x2M3D/src/template.jl:109
  (::Template)(::Dict{String, T}, ::Vector{OteraEngine.TmpBlock}) where T got unsupported keyword argument "tmp_init"
   @ OteraEngine ~/.julia/packages/OteraEngine/x2M3D/src/template.jl:125

Stacktrace:
 [1] kwerr(kw::@NamedTuple{tmp_init::Dict{String, String}}, args::Template)
   @ Base ./error.jl:165
 [2] top-level scope
   @ REPL[7]:1
``

## Steps to reproduce
To reproduce the error, just use the given example in the documentation website:
```julia
julia> using OteraEngine
julia> txt = "```using Dates; now()```. Hello {{ usr }}!"
julia> tmp = Template(txt, path = false)
julia> init = Dict("usr"=>"OteraEngine")
julia> tmp(tmp_init = init)

Solution

Replace tmp(tmp_init = init) with tmp(init = init). The code now works.

Could you update the documentation available in your documentation website?

Thank you very much, David

MommaWatasu commented 6 months ago

Thank you for your report. I’ll update the docs as soon as possible.

MommaWatasu commented 6 months ago

I updated the dev docs, and stable docs will be updated when I update the package. And (you may know) please note that the default jl code block has been changed from ```...``` to {<...>}. Enjoy making Templates with OteraEngine!