Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MommaWatasu committed Mar 27, 2024
2 parents d529d0b + 17bf16d commit 4ee3c2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
|:------------:|:------:|:--------:|
|[![CI][CI-img]][CI-url] |[![codecov][codecov-img]][codecov-url]|[![docs dev][docs-dev-img]][docs-dev-url] [![docs stable][docs-stable-img]][docs-stable-url]|

The stable docs is currently broken, so please take a look at the dev docs.

## Abstract
This is the template engine for JuliaLang.
features
Expand Down
14 changes: 10 additions & 4 deletions src/template.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"""
Template(txt::String; path::Bool=true, config_path::String="", config::Dict{String, String} = Dict())
Template(
txt::String;
path::Bool=true,
filters::Dict{String, Symbol},
config_path::String="",
config::Dict{String, String} = Dict()
)
This is the only structure and function of this package.
This structure has 4 parameter,
- `txt` is the path to the template file or template of String type.
Expand All @@ -9,16 +15,16 @@ This structure has 4 parameter,
- `config` is configuration of template. It is type of `Dict`, please see [configuraiton](#Configurations) for more detail.
# Rendering
After you create a Template, you just have to execute the codes! For this, you use the Function-like Object of Template structure.`tmp(; jl_init::Dict{String, String}, tmp_init::Dict{String, String})` variables are initialized by `jl_init`(for julia code) and `tmp_init`(for template code). These parameters must be `Dict` type. If you don't pass the `jl_init` or `tmp_init`, the initialization won't be done.
After you create a Template, you just have to execute the codes! For this, you use the Function-like Object of Template structure.`tmp(; init::Dict{String, T}) where {T}` variables are initialized by `init` Dict which contains the pair of name(String) and value. If you don't pass the `init`, the initialization won't be done.
# Example
This is a simple usage:
```julia-repl
julia> using OteraEngine
julia> txt = "```using Dates; now()```. Hello {{ usr }}!"
julia> txt = "Hello {{ usr }}!"
julia> tmp = Template(txt, path = false)
julia> init = Dict("usr"=>"OteraEngine")
julia> tmp(tmp_init = init)
julia> tmp(init = init)
```
"""
struct Template
Expand Down

0 comments on commit 4ee3c2c

Please sign in to comment.