[ANN] A new package Jinja.jl - Template Engine for JuliaLang

I’m grad to announce that I released the Jinja(Also, this is my first time to post here).

Jinja is the template engine for JuliaLang. features

  • Very very small! There are no dependency.
  • You can write a Julia code directly in HTML.

Jinja is a Template Engine, but it has a slightly different function from Python3 jinja2. It’s a function that allows you to write Julia code as it is in HTML! Because of this, it is very easy to write code to embed in the template. So you can write like this.

HTML Template File is:

<html>
    <head><title>JinjaPage</title></head>
    <body>
        The current time is <strong>
        `
        time
        `
        </strong>
        , and this is random number : `Int(round(rand()*100))`
    </body>
</html>

Julia code is:

using Jinja
using Dates

tmp = Template("./time.html") #The last HTML
init = Dict("time"=>now())
println(tmp(init))
#The current time comes in the last HTML code intead of the Julia code and returns it.

This code returns HTML of String type, like this:

<html>
    <head><title>JinjaPage</title></head>
    <body>
        The current time is <strong>
        2021-11-13T08:52:12.340
        </strong>
        , and this is random number : 37
    </body>
</html>

Please trying using Jinja.jl!

Resources

10 Likes

Looks nice. I do wonder about the name — Are you part of the Python Jinja2 team?

No.

Is it worth checking with them about using their name?

I haven’t checked with the Python Jinja team yet. I’ll rename it so as not to misunderstand.

1 Like

perhaps jin.jl? OTOH, there is a jinja.js.

thanks for the package, i love the django/jinja syntax.